Created
October 29, 2010 13:43
-
-
Save cassiomarques/653574 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 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