Skip to content

Instantly share code, notes, and snippets.

@ahorner

ahorner/brick.rb Secret

Created May 3, 2013 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ahorner/d545f3737f6e34accc7f to your computer and use it in GitHub Desktop.
Save ahorner/d545f3737f6e34accc7f to your computer and use it in GitHub Desktop.
Tales on Rails: The Three Little Devs
class Order < ActiveRecord::Base
#...
def self.with_profit_of_at_least(amount)
where { profit >= amount }
end
end
class Customer < ActiveRecord::Base
#...
def self.big_spenders
joins(:orders).uniq.merge(
Order.high_margin.with_profit_of_at_least(25000))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment