diff options
Diffstat (limited to 'activemodel/lib/active_model/errors.rb')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 6510629248..473bb7d9b7 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -92,7 +92,7 @@ module ActiveModel # Returns +true+ if the error messages include an error for the given key # +attribute+, +false+ otherwise. # - # person.errors.messages # => { :name => ["can not be nil"] } + # person.errors.messages # => { name: ["can not be nil"] } # person.errors.include?(:name) # => true # person.errors.include?(:age) # => false def include?(attribute) @@ -103,7 +103,7 @@ module ActiveModel # Get messages for +key+. # - # person.errors.messages # => { :name => ["can not be nil"] } + # person.errors.messages # => { name: ["can not be nil"] } # person.errors.get(:name) # => ["can not be nil"] # person.errors.get(:age) # => nil def get(key) @@ -177,7 +177,7 @@ module ActiveModel # Returns all message values. # - # person.errors.messages # => { :name => ["can not be nil", "must be specified"] } + # person.errors.messages # => { name: ["can not be nil", "must be specified"] } # person.errors.values # => [["can not be nil", "must be specified"]] def values messages.values @@ -185,7 +185,7 @@ module ActiveModel # Returns all message keys. # - # person.errors.messages # => { :name => ["can not be nil", "must be specified"] } + # person.errors.messages # => { name: ["can not be nil", "must be specified"] } # person.errors.keys # => [:name] def keys messages.keys @@ -240,8 +240,8 @@ module ActiveModel # 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.as_json # => { name: ["can not be nil"] } + # person.as_json(full_messages: true) # => { name: ["name can not be nil"] } def as_json(options=nil) to_hash(options && options[:full_messages]) end @@ -249,8 +249,8 @@ module ActiveModel # 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.to_hash # => { name: ["can not be nil"] } + # person.to_hash(true) # => { name: ["name can not be nil"] } def to_hash(full_messages = false) if full_messages messages = {} @@ -273,7 +273,7 @@ module ActiveModel # # => ["is invalid", "must be implemented"] # # person.errors.messages - # # => { :name => ["must be implemented", "is invalid"] } + # # => { name: ["must be implemented", "is invalid"] } # # If +message+ is a symbol, it will be translated using the appropriate # scope (see +generate_message+). @@ -306,7 +306,7 @@ module ActiveModel # # person.errors.add_on_empty(:name) # person.errors.messages - # # => { :name => ["can't be empty"] } + # # => { name: ["can't be empty"] } def add_on_empty(attributes, options = {}) [attributes].flatten.each do |attribute| value = @base.send(:read_attribute_for_validation, attribute) @@ -320,7 +320,7 @@ module ActiveModel # # person.errors.add_on_blank(:name) # person.errors.messages - # # => { :name => ["can't be blank"] } + # # => { name: ["can't be blank"] } def add_on_blank(attributes, options = {}) [attributes].flatten.each do |attribute| value = @base.send(:read_attribute_for_validation, attribute) |