Skip to content

Instantly share code, notes, and snippets.

@Slike9
Last active December 13, 2015 19:28
Show Gist options
  • Save Slike9/4962828 to your computer and use it in GitHub Desktop.
Save Slike9/4962828 to your computer and use it in GitHub Desktop.
local scope example
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