Hi -- On Thu, 28 Jun 2007, Giles Bowkett wrote: > On 6/27/07, Ball, Donald A Jr (Library) <donald.ball / nashville.gov> wrote: >> > ok, i will look that up. I am not looking to build a rails >> > app with this, i want to build a GUI app where our customers >> > can point different attributes to different models ( kinda >> > like setting a foriegn key dynamically, we are dealing with >> > lots of models here. So, i suppose i could store them in a >> > configuration file or something. >> >> I suspect you'd be much happier if these related attributes inherited >> from the same supermodel and used single-table inheritance, or if you >> used polymorphic associations instead. The latter sounds like it's more >> appropriate to your situation, but if your attribute models have similar >> characteristics, the former would be a better fit. >> >> Either sound more reasonable than mucking about with monkey-patching the >> class at run-time. Not nearly as much fun, mind you, but that's not >> always the best thing for which to optimize. > > You can do that: > > Foo.class_eval("has_many :bars") I think you could just do: Foo.has_many :bars However... > But I think it could be an utterly heinous mess. You'd need the DB to > morph in an equivalently dynamic way, which is nontrivial. ...I totally agree about the heinous mess :-) David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)