Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Rails3 version of errors.add_to_base?

I want to write a custom validation in Rails 3, but following this example I get:

'ActiveModel::DeprecatedErrorMethods.add_to_base' call is deprecated in Rails 3.0 

What is the rails3 version of:

def validate    errors.add_to_base "If you are attaching a file you must enter a label for it" if !attachment.blank? and attachment_label.blank? end 
like image 240
Marius Butuc Avatar asked Jan 20 '11 20:01

Marius Butuc


1 Answers

This should work in rails 3.1.3:

errors.add :base, "message" 
like image 161
Drew Johnson Avatar answered Oct 02 '22 16:10

Drew Johnson