In rails 2 you could use proxy_options
to see the options for specific database queries. In rails 3 it has been removed. Is there a different option for getting this same info?
Asked
Active
Viewed 983 times
3

Lan
- 6,039
- 7
- 22
- 24
-
Possible duplicate - http://stackoverflow.com/questions/3025103/how-to-test-a-scope-in-rails-3 – sethvargo Jan 11 '11 at 04:49
-
Not a dupe, the linked question is about how to test a scope. My question is about knowing what the scoped query looks like. – Lan Jan 11 '11 at 05:40
2 Answers
2
I posted a long answer here: How to test a scope in Rails 3
But the main answer is use #where_values_hash or #to_sql on your scope.
-
Or `where_values`. So you might do: `User.joins(:address).where(Address.foreign.where_values)`. – Henrik N Feb 21 '12 at 15:39
-
Note: `where_values_hash` doesn't seem to work everywhere; doesn't work when chained with `not` (including scopes chained as such). Reference: https://github.com/rails/rails/issues/23613 (doesn't look like it's being worked on at this time) – Jay Dorsey Mar 09 '20 at 22:28