I've written an ActiveRecord extension that allows Associations to be automatically generated at runtime without requiring "has_many" and "belongs_to" to be defined in the class. The use of has_many vs has_one is determined by the pluralisation of the method call.

Additionally, it uses the :null => false attribute of columns to provide validates_presence_of automatically to models too.

If any of this code is relevant for Core Rails, let me know and I'll extract it from the gem and create a patch for core. The gem has received a good reception on the Ruby + RoR forums.

http://drnicwilliams.com/2006/08/07/ann-dr-nics-magic-models/

Cheers
Nic

--
Dr Nic Williams
http://www.drnicwilliams.com - Ruby/Rails blog
skype: nicwilliams
(m) +31 62 494 8552
(p) +61 7 3305 7522 (finds me anywhere in the world)
(f) +61 7 3305 7572 (sends fax to my email)

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to