On Feb 13, 2:43 pm, Matt Jones <[email protected]> wrote: > On Feb 12, 2:13 pm, Jim <[email protected]> wrote: > > > Although, I have to wonder if there's a better way to > > accomplish this than through method_missing. Maybe there's some way > > to loop through all attributes and call alias_attribute dynamically > > when classes are loaded? > > There is - try this: > > class LegacyModel < ActiveRecord::Base > column_names.each do |c| > # figure out the new name > alias_attribute new_name, c > end > end > > --Matt Jones
This would work in a regular model, but not a model with abstract_class set to true. LegacyModel is an abstract class that other models inherit from, so I do not have to repeat certain things which apply to all legacy tables in the database, like setting the primary key, certain alias_attribute calls, and a few other things. Jim --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

