AR Objects saved with Errors

If I remember correctly, adding an error to an AR object's attribute or :base previously prevented the object from being saved. This is not the current behavior of Active Record.

user = User.last user.errors.add :name, "name doesn't rhyme with orange" user.valid? # => true user.save # => true

user = User.last user.errors.add :base, "my unique error" user.valid? # => true user.save # => true

Is that an intentional change, or an accidental one? Would a patch preventing objects with errors from saving be considered?

valid? resets the state of errors, this has been the case for years:

https://github.com/rails/rails/blob/2-3-stable/activerecord/lib/active_record/validations.rb#L1107

You can only add to errors during the validation callbacks if you want to prevent the save from happening