method

add_to_base

Importance_3
v1.2.6 - Show latest stable - 2 notes - Class: ActiveRecord::Errors
add_to_base(msg) public

Adds an error to the base object instead of any particular attribute. This is used to report errors that don’t tie to any specific attribute, but rather to the object as a whole. These error messages don’t get prepended with any field name when iterating with each_full, so they should be complete sentences.

Show source
Register or log in to add new notes.
August 13, 2010
10 thanks

add_to_base in Rails 3

use

model_instance.errors[:base] << "Msg" 

instead of depracated

model_instance.errors.add_to_base("Msg")

for Rails 3

June 20, 2012 - (>= v3.0.0)
1 thank

add_to_base in Rails 3

In addition to stevo’s note, in Rails 3 you can also do:

model_instance.errors.add(:base, "Msg")