Class

Errors

Extends:

Includes:

Active Resource validation is reported to and from this object, which is used by Base#save to determine whether the object in a valid state to be saved. See usage example in Validations.

Public Attributes
errors
Public Methods
[] Alias for #on
add Adds an error to an Active Resource object’s attribute (named for the attribute parameter) with the error message in msg.
add_to_base Add an error to the base Active Resource object rather than an attribute.
clear
count Alias for #size
each Yields each attribute and associated message per error added.
each_full Yields each full error message added. So Person.errors.add("first_name", "can’t be empty") will be returned through iteration as "First name can’t be empty".
from_xml Grabs errors from the XML response.
full_messages Returns all the full error messages in an array.
invalid? Returns true if the specified attribute has errors associated with it.
length Alias for #size
new
on A method to return the errors associated with attribute, which returns nil, if no errors are associated with the specified attribute, the error message if one error is associated with the specified attribute, or an array of error messages if more than one error is associated with the specified attribute.
on_base A method to return errors assigned to base object through add_to_base, which returns nil, if no errors are associated with the specified attribute, the error message if one error is associated with the specified attribute, or an array of error messages if more than one error is associated with the specified attribute.
size Returns the total number of errors added. Two errors added to the same attribute will be counted as such with this as well.
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.