Although I'm adding an error to :captcha, when I raise @comment.valid?
on the next line this still gives me true! Why is that? I just added an
error to @comment, didn't I?!
Maybe it's because I'm only using an attr_accessor for captcha?
class Comment < ActiveRecord::Base
validates_presence_of :captcha
attr_accessor :captcha
end
results in "errors: #<ActiveRecord::Errors:0x1878538 @base=#<Comment id:
nil, commentable_id: 38313, user_id: 1, subject: "", body: "",
created_at: nil, updated_at: nil, commentable_type: "Article">,
@errors={"base"=>["Captcha wurde nicht korrekt eingegeben"]}>"
Why the heck does ActiveRecord remove my custom errors when calling
.valid???
Calling valid? recomputes the errors (there's no difference at the end
of the day between an error you added yourself and one from a 'normal'
validations. If you want to add errors yourself you should be doing so
from a validation