Created
May 28, 2019 15:55
-
-
Save talum/c319660520b3799a2f898bfd4ca4e6c2 to your computer and use it in GitHub Desktop.
Invoice Model
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
class Invoice < ActiveRecord::Base | |
validates_presence_of :amount_due, :due_date, :scheduled_send_date | |
validate :closeable_if_unpaid | |
def closeable_if_unpaid | |
if paid_at.present? && closed_at.present? | |
errors.add(:closed_at, "cannot be closed") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment