method
add_to_base
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.
Register or
log in
to add new notes.
stevo -
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
kapitan-petko -
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")