method

add

Importance_1
v2.0.3 - Show latest stable - 0 notes - Class: ActiveResource::Errors
add(attribute, msg) public

Adds an error to an Active Resource object’s attribute (named for the attribute parameter) with the error message in msg.

Examples

  my_resource = Node.find(1)
  my_resource.errors.add('name', 'can not be "base"') if my_resource.name == 'base'
  my_resource.errors.on('name')
  # => 'can not be "base"!'

  my_resource.errors.add('desc', 'can not be blank') if my_resource.desc == ''
  my_resource.valid?
  # => false
  my_resource.errors.on('desc')
  # => 'can not be blank!'
Show source
Register or log in to add new notes.