Created
January 2, 2018 13:29
-
-
Save bogdan/3a06bfc1ab6eda0ea5a10c47579baec3 to your computer and use it in GitHub Desktop.
This file contains 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
where(person_id: Person.find_by(email: email, site_id: site_id), site_id: site_id) | |
} | |
+ scope :by_coupon_list, ->(coupon_list_id) { | |
+ sub_query = Coupon. | |
+ joins('INNER JOIN `checkout_coupons` ON `checkout_coupons`.`coupon_id` = `coupons`.`id`'). | |
+ where('`origins`.`id` = `checkout_coupons`.`purchase_id`').where(coupon_list_id: coupon_list_id) | |
+ where("exists (#{sub_query.to_sql})") | |
+ } | |
+ | |
scope :with_mobile_visitor, ->(mobile) { | |
return if mobile.nil? | |
joins(:visitor).merge(Visitor.mobile(mobile)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment