Last active
December 13, 2015 19:28
-
-
Save Slike9/4962828 to your computer and use it in GitHub Desktop.
local scope example
This file contains hidden or 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
module Reporting::OrderScopes | |
# Returns orders with the scopes injected. | |
def self.inject_to(orders) | |
orders.scoped.extend(self) | |
end | |
# scopes | |
def payed | |
where("paid_at IS NOT NULL") | |
end | |
def payed_today | |
paid.where("DATE(paid_at) = ?", Date.today) | |
end | |
def for_daily_report | |
select(:id, :payed_at, :sum) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment