Created
November 5, 2014 18:27
-
-
Save JasonY1/b9518ccf14b5d158d026 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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