Ruby on Rails: errors.add_to_base vs. errors.add

It’s worth noting (since this shows up in the search engines, which is how I found it) that this is deprecated. The Rails 3 way of doing it is below but is no longer valid as of Rails 7 (see the comment from April 2022)

errors[:base] << "Error message"    

the preferred way of doing it is

errors.add(:base, "Error message")

http://apidock.com/rails/ActiveRecord/Errors/add_to_base
http://apidock.com/rails/v3.2.8/ActiveModel/Errors/add

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)