Skip to content

Instantly share code, notes, and snippets.

@talum
Created May 28, 2019 15:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save talum/c319660520b3799a2f898bfd4ca4e6c2 to your computer and use it in GitHub Desktop.
Save talum/c319660520b3799a2f898bfd4ca4e6c2 to your computer and use it in GitHub Desktop.
Invoice Model
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