Commit 0eef0ab403b484485a38b6753fcfd0b0a76cbd7f
1 parent
792627d4
Exists in
master
and in
1 other branch
add monkey patch for handling association queries
source: https://developer.uservoice.com/blog/2012/03/04/how-to-upgrade-a-rails-2-3-app-to-ruby-1-9-3/ https://gist.github.com/cypriss/1976864
Showing
1 changed file
with
13 additions
and
0 deletions
Show diff stats
| @@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
| 1 | +# Finally, we have this innocuous looking patch. Without it, queries like this: current_account.tickets.recent.count | ||
| 2 | +# would instantiate AR objects all (!!) tickets in the account, not merely return a count of the recent ones. | ||
| 3 | +# See https://rails.lighthouseapp.com/projects/8994/tickets/5410-multiple-database-queries-when-chaining-named-scopes-with-rails-238-and-ruby-192 | ||
| 4 | +# (The patch in that lighthouse bug was not, in fact, merged in). | ||
| 5 | +module ActiveRecord | ||
| 6 | + module Associations | ||
| 7 | + class AssociationProxy | ||
| 8 | + def respond_to_missing?(meth, incl_priv) | ||
| 9 | + false | ||
| 10 | + end | ||
| 11 | + end | ||
| 12 | + end | ||
| 13 | +end |