Have you looked at "Dr. Nic's Magic Models"? It's hosted on RubyForge at http://magicmodels.rubyforge.org/
While it doesn't do exactly what you ask, I bet you'd get a pretty good jump-start by seeing behind the curtain.
Rob Biedenharn http://agileconsultingllc.com
Keep up to date with Rails on Twitter and This Week in Rails
Policies: Conduct, License, Maintenance, Security, Trademarks