Skip to content

Instantly share code, notes, and snippets.

@matthandlersux
Created December 15, 2011 00:59
Show Gist options
  • Save matthandlersux/1479353 to your computer and use it in GitHub Desktop.
Save matthandlersux/1479353 to your computer and use it in GitHub Desktop.
validation order
# works:
with_options :if => Proc.new {|r| !r.session_based? } do |o|
o.validates_presence_of :event_date, :giver, :title
end
with_options :if => Proc.new {|r| !r.session_based? && !r.event_date.nil? } do |o|
o.validate :money_due_date_before_event_date
o.validate :gift_votes_date_if_no_idea_selected
o.validate :gift_votes_date_before_other_dates
end
# vs doesn't work:
with_options :if => Proc.new {|r| !r.session_based? } do |o|
o.validates_presence_of :event_date, :giver, :title
o.validate :money_due_date_before_event_date
o.validate :gift_votes_date_if_no_idea_selected
o.validate :gift_votes_date_before_other_dates
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment