Created
May 23, 2016 10:44
-
-
Save bsylvain/ec6d70e31184c43a49a03cd7570522d9 to your computer and use it in GitHub Desktop.
the same query does not act the same depending on if it is used in scope or directly
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
| scope :by_shop_id,->{ | |
| joins(:shop_data_for_users).where("shop_data_for_users.shop_id = ? and shop_data_for_users.specific_id= ?",2,'4').first | |
| } | |
| #console : | |
| u = User.by_shop_id | |
| u.count | |
| #SELECT COUNT(*) FROM "users" | |
| u = User.joins(:shop_data_for_users).where("shop_data_for_users.shop_id = ? and shop_data_for_users.specific_id= ?",2,'4').first | |
| =>nil | |
| # |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment