-
-
Save Rio517/01f193794402b9aa734d to your computer and use it in GitHub Desktop.
further revision
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 Order < ActiveRecord::Base | |
#... | |
scope :high_margin, where('price_to_manufacture * 10 <= profit') | |
scope :with_profit_of_at_least, lambda{|account| where('profit >= ?', amount) } | |
end | |
class Customer < ActiveRecord::Base | |
has_many :orders | |
scope :big_spenders, joins(:orders).merge(Order.high_margin.with_profit_of_at_least(25000)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment