Permalink
Browse files

Merge pull request #11757 from ryog/fix_document_active_model_errors

Fix: documentation for ActiveModel::Errors [ci skip]
  • Loading branch information...
1 parent 3231506 commit 8c9498140e3ddecd9afef2df99ecf6ab25437f63 @rafaelfranca rafaelfranca committed Aug 5, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 activemodel/lib/active_model/errors.rb
@@ -238,17 +238,17 @@ def to_xml(options={})
# object. You can pass the <tt>:full_messages</tt> option. This determines
# if the json object should contain full messages or not (false by default).
#
- # person.as_json # => {:name=>["can not be nil"]}
- # person.as_json(full_messages: true) # => {:name=>["name can not be nil"]}
+ # person.errors.as_json # => {:name=>["can not be nil"]}
+ # person.errors.as_json(full_messages: true) # => {:name=>["name can not be nil"]}
def as_json(options=nil)
to_hash(options && options[:full_messages])
end
# Returns a Hash of attributes with their error messages. If +full_messages+
# is +true+, it will contain full messages (see +full_message+).
#
- # person.to_hash # => {:name=>["can not be nil"]}
- # person.to_hash(true) # => {:name=>["name can not be nil"]}
+ # person.errors.to_hash # => {:name=>["can not be nil"]}
+ # person.errors.to_hash(true) # => {:name=>["name can not be nil"]}
def to_hash(full_messages = false)
if full_messages
messages = {}

0 comments on commit 8c94981

Please sign in to comment.