Created
October 9, 2013 16:51
-
-
Save biagidp/6904441 to your computer and use it in GitHub Desktop.
This file contains 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
open_study = Study.where(status: "Open to Accrual").first | |
fields = [self.status, self.date, open_study, open_study.date] | |
if((self.status != "Open to Accrual") && (fields.all?(&:present?)) && (self.date < open_study.date)) | |
errors.add(:date, :greater_than_open_date) | |
end | |
#VS | |
open_study = Study.where(status: "Open to Accrual").first | |
unless self.status == "Open to Accrual" | |
if self.status && self.date && open_study && open_study.date | |
if self.date < open_study.date | |
errors.add(:date, :greater_than_open_date) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment