From 0eef0ab403b484485a38b6753fcfd0b0a76cbd7f Mon Sep 17 00:00:00 2001 From: Luke Baker Date: Mon, 20 May 2013 13:09:52 -0400 Subject: [PATCH] add monkey patch for handling association queries --- lib/rails23_ruby193_ar_associations_monkey_patch.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+), 0 deletions(-) create mode 100644 lib/rails23_ruby193_ar_associations_monkey_patch.rb diff --git a/lib/rails23_ruby193_ar_associations_monkey_patch.rb b/lib/rails23_ruby193_ar_associations_monkey_patch.rb new file mode 100644 index 0000000..a562acb --- /dev/null +++ b/lib/rails23_ruby193_ar_associations_monkey_patch.rb @@ -0,0 +1,13 @@ +# Finally, we have this innocuous looking patch. Without it, queries like this: current_account.tickets.recent.count +# would instantiate AR objects all (!!) tickets in the account, not merely return a count of the recent ones. +# See https://rails.lighthouseapp.com/projects/8994/tickets/5410-multiple-database-queries-when-chaining-named-scopes-with-rails-238-and-ruby-192 +# (The patch in that lighthouse bug was not, in fact, merged in). +module ActiveRecord + module Associations + class AssociationProxy + def respond_to_missing?(meth, incl_priv) + false + end + end + end +end -- libgit2 0.21.2