Forum: Ruby xxx.valid? still true after xxx.errors.add(...)?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Joshua M. (Guest)
on 2009-04-20 13:06
Hi all

I have the following code in my controller:

    if @comment.valid?
      captcha_url =
      result = open(captcha_url)
      unless == "1"
        @comment.errors.add(:captcha, "Captcha wurde nicht korrekt
        raise "#{@comment.valid?}"

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?!

Joshua M. (Guest)
on 2009-04-20 13:16
I'm sorry, this belongs to the RoR part of this forum... I'll re-post it
This topic is locked and can not be replied to.