test_persisted?

test_persisted?() Instance Public methods Responds to persisted? Returns a boolean that specifies whether the object has been persisted yet. This is used when calculating the URL for an object. If the object is not persisted, a form for that object, for instance, will route to the create action. If it is persisted, a form for the object will routes to the update action.

test_model_naming

test_model_naming() Instance Public methods Naming Model.model_name must return a string with some convenience methods: :human, :singular and :plural. Check ActiveModel::Naming for more information.

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.

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"]]

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>

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_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"]

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

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"]

keys

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