Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Rio517

Rio517/brick2.rb Secret

Forked from ahorner/brick.rb
Last active December 17, 2015 03:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Rio517/01f193794402b9aa734d to your computer and use it in GitHub Desktop.
Save Rio517/01f193794402b9aa734d to your computer and use it in GitHub Desktop.
further revision
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