Skip to content

Instantly share code, notes, and snippets.

@cassiomarques
Created October 29, 2010 13:43
Show Gist options
  • Save cassiomarques/653574 to your computer and use it in GitHub Desktop.
Save cassiomarques/653574 to your computer and use it in GitHub Desktop.
class SectionType < EnumerateIt::Base
asociate_values(
:type_a => 1,
:type_b => 2
)
end
class Section < ActiveRecord::Base
# não precisa passar a opcao :with pois o nome do atributo coincide
# com o nome da enumeration
has_enumeration_for :section_type
end
section = Section.new(:section_type => SectionType::TYPE_A)
section.section_type # => 1
section.section_type_humanize # 'Type A' ou o que estiver mapeado no seu arquivo de locale i18n.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment