Skip to content

Instantly share code, notes, and snippets.

@biagidp
Created October 9, 2013 16:51
Show Gist options
  • Save biagidp/6904441 to your computer and use it in GitHub Desktop.
Save biagidp/6904441 to your computer and use it in GitHub Desktop.
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