Skip to content

Instantly share code, notes, and snippets.

@kklimuk
Created April 3, 2017 04:53
Show Gist options
  • Save kklimuk/3fb1c7a8a73de2a3a9efb220da884d89 to your computer and use it in GitHub Desktop.
Save kklimuk/3fb1c7a8a73de2a3a9efb220da884d89 to your computer and use it in GitHub Desktop.
memoized
def users_with_discounts(scoped_to={})
users = User.includes(payment_plan: :discounts).where(paying: true, **scoped_to).to_a
users.select do |users|
users.payment_plan.discounts.any? && !users.payment_plan.delayed?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment