diff options
-rw-r--r-- | activemodel/CHANGELOG.md | 15 | ||||
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index e4c80b1bf8..9aee47bd52 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,7 +1,18 @@ ## Rails 4.0.0 (unreleased) ## -* Add ActiveModel::Errors#full_messages_for, a method that returns all the error - messages for a given attribute. +* Add `ActiveModel::Errors#full_messages_for`, to return all the error messages + for a given attribute. + + class Person + include ActiveModel::Validations + + attr_reader :name, :email + validates_presence_of :name, :email + end + + person = Person.new + person.valid? # => false + person.errors.full_messages_for(:name) # => ["Name can't be blank"] *Volodymyr Shatsky* diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 485eb1a40a..b60458b3c6 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -12,7 +12,6 @@ module ActiveModel # A minimal implementation could be: # # class Person - # # # Required dependency for ActiveModel::Errors # extend ActiveModel::Naming # @@ -40,7 +39,6 @@ module ActiveModel # def Person.lookup_ancestors # [self] # end - # # end # # The last three methods are required in your object for Errors to be |