Changing model attribute names



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 G.



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

def street_address=(addr)
write_attribute(:address1, addr)

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