module
v3.2.8 -
Show latest stable
-
1 note
Register or
log in
to add new notes.
mcmire -
June 12, 2009
1 thank
Conditions work for lower-level validate methods too
I don’t think this is mentioned in the docs anywhere, or else I couldn’t find it: Because validate, validate_on_create, and validate_on_update are ActiveSupport::Callbacks, their symbol forms support conditions just like validates_presence_of and company:
validate :permaname_must_be_unique, :if => :normal_entry? validate_on_create :posted_at_must_be_valid_timestamp, :unless => Proc.new {|e| e.posted_at.nil? } validate_on_update :title_must_not_contain_apostrophes, :if => :title_starts_with_a_b?