communication between input and attribute

user input something simple to write
attributes in db use some complicated name to easy understand

several ways to solve this translation between user input and db objects
1) interpret user input to db objects at the level of user input leavel, maybe a name mapping?
2) update the attributes in the rails model
def attribute=(val)
pp = case val.ucase
when ‘F’ then ‘female’
when ‘M’ then ‘male’
else val
end
write_attribute(:attribute, pp)
end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s