README.rdoc in enumerate_it-0.1.0 vs README.rdoc in enumerate_it-0.2.0

- old
+ new

@@ -64,11 +64,11 @@ * You can get an array of options, ready to use with the 'select', 'select_tag', etc family of Rails helpers. RelationshipStatus.to_a # [["Divorced", 4],["Married", 2],["Single", 1],["Widow", 3]] -* You can manipulate the has used to create the enumeration: +* You can manipulate the hash used to create the enumeration: RelationshipStatus.enumeration # returns the exact hash used to define the enumeration == Using enumerations @@ -88,19 +88,29 @@ p = Person.new p.relationship_status = RelationshipStatus::DIVORCED p.relationsip_status_humanize # => 'Divorced' -* If your class can manage validations and responds to :validates_inclusion_of, it will create this -validation: +* If you pass the :create_helpers option as 'true', it will create a helper method for each enumeration option (this option defaults to false): - class Person < ActiveRecord::Base - has_enumeration_for :relationship_status, :with => RelationshipStatus - end + class Person < ActiveRecord::Base + has_enumeration_for :relationship_status, :with => RelationshipStatus, :create_helpers => true + end - p = Person.new :relationship_status => 6 # => there is no '6' value in the enumeration - p.valid? # => false - p.errors[:relationship_status] # => "is not included in the list" + p = Person.new + p.relationship_status = RelationshipStatus::MARRIED + p.married? #=> true + p.divorced? #=> false + +* If your class can manage validations and responds to :validates_inclusion_of, it will create this validation: + + class Person < ActiveRecord::Base + has_enumeration_for :relationship_status, :with => RelationshipStatus + end + + p = Person.new :relationship_status => 6 # => there is no '6' value in the enumeration + p.valid? # => false + p.errors[:relationship_status] # => "is not included in the list" Remember that in Rails 3 you can add validations to any kind of class and not only to those derived from ActiveRecord::Base. == Installation