Skip to content

Instantly share code, notes, and snippets.

@radar
Forked from DriesS/scope.rb
Created October 24, 2012 08:01
Show Gist options
  • Save radar/3944691 to your computer and use it in GitHub Desktop.
Save radar/3944691 to your computer and use it in GitHub Desktop.
Name scope use self.id
class Discount < ActiveRecord::Base
def unused
self.orders.
where(:state => ['shipped', 'paid', 'completed', 'processing']).
where(:user_id => user.id).
count
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment