#validate does not seem to work correctly with :on => :create/:update

Posted by Tobias on Stack Overflow See other posts from Stack Overflow or by Tobias
Published on 2010-06-02T07:18:46Z Indexed on 2010/06/02 7:23 UTC
Read the original article Hit count: 408

Filed under:
|
|

Greetings,

I have a custom validation in my exemplary Movie model:

class Movie < ActiveRecord::Base
  validate :it, :on => :create

  private

  def it
    self.errors.add 'foo', 'bar'
  end
end

This works on movie creation but also on updating an existing movie. :on => :update will also work for both. Might that be a bug or am I missing something?

Best regards

Tobias

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about validation