Skip to content

Instantly share code, notes, and snippets.

@cassiomarques
Created February 11, 2011 02:05
Show Gist options
  • Save cassiomarques/821793 to your computer and use it in GitHub Desktop.
Save cassiomarques/821793 to your computer and use it in GitHub Desktop.
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