Reputation: 1182
I have a hash of marital statuses, which looks like this...
marital_hash = {"Unknown" => "U", "Married" => "M", "Single" => "S", "Widowed" => "W", "Divorced" => "D", "Separated" => "S", "Civil Partner" => "C"}
Then I have a user model, which has an attribute of :marital_status. The values of the marital_status are identical to the keys in the hash. How do I call the value of the hash for each employee based on their :marital_status?
Upvotes: 0
Views: 35
Reputation: 1150
marital_hash[user.marital_status]
should give you the appropriate value on the hash.
Upvotes: 1