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.
Very cool stuff, Nic. I think it would be a great app/plugin to use against databases that follow Rails conventions but that does not necessarily have a Rails application already. I don't think its a good fit for core, though. Primarily because it splinters the overview. I don't have any models in any of my real applications where the automatically defined rules would be sufficient. And when they're not, it means that my validates_format_of will have to be defined explicitly while the validates_presence_of is magic. Or that my has_many :comments, :order => "created_at DESC" has to be explicit, but my has_one :author is automatic. But again, please do keep pushing on with this. Just because its not a good fit for core, doesn't mean it ain't cool. Rock on. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework _______________________________________________ Rails-core mailing list Rails-core@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-core