has_key?

has_key?(attribute) Instance Public methods aliases include? include?

include?

include?(attribute) Instance Public methods Returns true if the error messages include an error for the given key attribute, false otherwise. person.errors.messages # => {:name=>["cannot be nil"]} person.errors.include?(:name) # => true person.errors.include?(:age) # => false has_key?

keys

keys() Instance Public methods Returns all message keys. person.errors.messages # => {:name=>["cannot be nil", "must be specified"]} person.errors.keys # => [:name]

set

set(key, value) Instance Public methods Set messages for key to value. person.errors.get(:name) # => ["cannot be nil"] person.errors.set(:name, ["can't be nil"]) person.errors.get(:name) # => ["can't be nil"]

size

size() Instance Public methods Returns the number of error messages. person.errors.add(:name, "can't be blank") person.errors.size # => 1 person.errors.add(:name, "must be specified") person.errors.size # => 2

to_a

to_a() Instance Public methods Returns an array of error messages, with the attribute name included. person.errors.add(:name, "can't be blank") person.errors.add(:name, "must be specified") person.errors.to_a # => ["name can't be blank", "name must be specified"]

to_hash

to_hash(full_messages = false) Instance Public methods Returns a Hash of attributes with their error messages. If full_messages is true, it will contain full messages (see full_message). person.errors.to_hash # => {:name=>["cannot be nil"]} person.errors.to_hash(true) # => {:name=>["name cannot be nil"]}

to_xml

to_xml(options={}) Instance Public methods Returns an xml formatted representation of the Errors hash. person.errors.add(:name, "can't be blank") person.errors.add(:name, "must be specified") person.errors.to_xml # => # <?xml version=\"1.0\" encoding=\"UTF-8\"?> # <errors> # <error>name can't be blank</error> # <error>name must be specified</error> # </errors>

values

values() Instance Public methods Returns all message values. person.errors.messages # => {:name=>["cannot be nil", "must be specified"]} person.errors.values # => [["cannot be nil", "must be specified"]]

test_errors_aref

test_errors_aref() Instance Public methods Errors Testing Returns an object that implements [](attribute) defined which returns an Array of Strings that are the errors for the attribute in question. If localization is used, the Strings should be localized for the current locale. If no error is present, this method should return an empty Array.