Skip to content

Instantly share code, notes, and snippets.

@kklimuk
Created April 3, 2017 04:50
Show Gist options
  • Save kklimuk/429c945bacd48b5f9fdb558940310225 to your computer and use it in GitHub Desktop.
Save kklimuk/429c945bacd48b5f9fdb558940310225 to your computer and use it in GitHub Desktop.
def users_with_discounts
return @users_with_discounts unless @users_with_discounts.nil?
users = User.includes(payment_plan: :discounts).where(paying: true).to_a
@users_with_discounts = 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