# File /Users/nshb/svn/svn.inimit.com/railsmanual.com/www/trunk/src/rails-2.0.0/activeresource/lib/active_resource/validations.rb, line 50 def add(attribute, msg) @errors[attribute.to_s] = [] if @errors[attribute.to_s].nil? @errors[attribute.to_s] << msg end
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!'