Skip to content

Instantly share code, notes, and snippets.

@JasonY1
Created November 5, 2014 18:27
Show Gist options
  • Select an option

  • Save JasonY1/b9518ccf14b5d158d026 to your computer and use it in GitHub Desktop.

Select an option

Save JasonY1/b9518ccf14b5d158d026 to your computer and use it in GitHub Desktop.
class Event < ActiveRecord::Base
validates :title, :start_date, presence: true
validate :startdate_before_enddate
def startdate_before_enddate
if :end_date.present?
unless :start_date < :end_date
errors.add(:start_date, "must be before end date")
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment