Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. class Invoice < ActiveRecord::Base
  2. validate :expiration_date_cannot_be_in_the_past,
  3. :discount_cannot_be_greater_than_total_value
  4.  
  5. def expiration_date_cannot_be_in_the_past
  6. if expiration_date.present? && expiration_date < Date.today
  7. errors.add(:expiration_date, "can't be in the past")
  8. end
  9. end
  10. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement