diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-03-30 14:38:12 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-03-30 14:38:13 -0300 |
commit | 3d0c0c6c95f8ed35c3fea79cfe93ec6e74f726ec (patch) | |
tree | 23d3f94111ee9f5d0c3ecc4d4f10b8390051f4cc /activemodel | |
parent | 7860bf11d862a6eb1bd9ada85bcd97f17a2cb536 (diff) | |
download | rails-3d0c0c6c95f8ed35c3fea79cfe93ec6e74f726ec.tar.gz rails-3d0c0c6c95f8ed35c3fea79cfe93ec6e74f726ec.tar.bz2 rails-3d0c0c6c95f8ed35c3fea79cfe93ec6e74f726ec.zip |
Improve changelog entry for ActiveModel::Errors#full_messages_for [ci skip]
Add a working example of how to use this new method.
Diffstat (limited to 'activemodel')
-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 |