Skip to content

Instantly share code, notes, and snippets.

@wallace
Created August 7, 2012 11:43
Show Gist options
  • Select an option

  • Save wallace/3284741 to your computer and use it in GitHub Desktop.

Select an option

Save wallace/3284741 to your computer and use it in GitHub Desktop.
class Order < ActiveRecord::Base
has_many :line_items
validates :total_price, numericality: true
before_create :apply_returning_customer_discount, if: lambda { |order| order.returning_customer? }
def apply_returning_customer_discount
self.total_price = self.total_price * 0.9
end
end
@stevenharman

Copy link
Copy Markdown

s/crass/snarky/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment