Mike B wrote in post #966542: > Thanks for the suggestion. Please quote when replying -- I have no idea whom you're thanking for what suggestion.
> Gave it a try but it appears that support > for aliased columns does not run very deep in ActiveRecord. > > For example, if you alias obj_id to object_id and then try to do: > Object.find_by_obj_id(3) it complains that the method is unknown. But find_by_object_id should work. > > I did a bit of digging on sqlite3 updateable views and it appears that > this can be accomplished by writing some triggers. Same applies for > postgres and others as well. > > Barring an absolutely brilliant suggestion I'm going to pursue this > solution. Please don't do that yet. Spend some more time with aliased attributes -- you shouldn't need to write a view for something this simple. If it were my DB, I'd either use alias_attribute or something like Philip's solution. There should be no need for views here. Actually, I'd probably change the name of the field. The legacy application shouldn't be a concern: no two applications should directly touch the same DB anyway IMHO. Another good idea might be to have the legacy application expose a REST service (with any field names you like!) that the Rails application can interact with by using ActiveResource (this is sort of what we've done here at my job). If you *do* need DB views, try the rails_sql_views plugin. > > Thanks to all, > Mike Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

