Updated: assignable_values can now humanize any given value, even if it's not the current attribute

Posted . Visible to the public.

You've always been able to access the humanized version for the current value like this:

song = Song.new(:genre => 'pop')
song.humanized_genre # => 'Pop music'

You can now also retrieve the humanized version of any given value by passing it as an argument:

song.humanized_genre('rock') # => 'Rock music'
Profile picture of Henning Koch
Henning Koch
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2012-07-31 10:45)