Hello, If I have a legacy db table named Users with a string named ''address1'' how can I map that to a User model with an attribute named ''street_address''? I recognize how much easier it would be just to use addess1 but some of the other columns have horrible names. Thank you, Ryan Glover -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
christopher.eagan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Dec-27 18:05 UTC
Re: Changing model attribute names
Ryan- Have you tried creating accessors to make your User class appear to have the street_address attribute? E.G. within your User class... ----------------------------------------- def street_address read_attribute(:address1) end def street_address=(addr) write_attribute(:address1, addr) end ------------------------------------------ You may also perhaps override the default accessors for address1 to make them no-ops if you wanted to discourage such access. Hope that helps! Chris Eagan --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---