Created
February 11, 2011 02:05
-
-
Save cassiomarques/821793 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreatePersons < ActiveRecord::Migration | |
def self.up | |
create_table do |t| | |
t.integer :relationship_status | |
t.string :name | |
end | |
end | |
end | |
class RelationshipStatus < EnumerateIt::Base | |
associate_values( | |
:married => 1, | |
:single => 2 | |
) | |
end | |
class Person < ActiveRecord::Base | |
include EnumerateIt | |
has_enumeration_for :relationship_status | |
end | |
person = Person.create! :relationship_status => RelationshipStatus::MARRIED, :name => "John Doe" | |
person.relationship_status_humanize # => Married | |
person.relationship_status # => 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment