Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Small performance improvement for Rails 3, but not as satisfying as t…

…aking the conditions and joins from the original scope and applying them to a new scope. Haven't found out how to do that in Rails 3.0 yet :(
  • Loading branch information...
commit 9385e172d679fa5d53017229450837c0a722f67a 1 parent 59c2a5a
Tom-Eric Gerritsen authored June 01, 2010
4  lib/acts_as_taggable_on/acts_as_taggable_on/collection.rb
@@ -115,7 +115,9 @@ def all_tag_counts(options = {})
115 115
         if ActiveRecord::VERSION::MAJOR >= 3
116 116
           # Append the current scope to the scope, because we can't use scope(:find) in RoR 3.0 anymore:
117 117
           scoped_select = "#{table_name}.#{primary_key}"
118  
-          tagging_scope = tagging_scope.where("#{ActsAsTaggableOn::Tagging.table_name}.taggable_id IN(#{select(scoped_select).to_sql})").
  118
+          scoped_sql    = select(scoped_select).to_sql
  119
+
  120
+          tagging_scope = tagging_scope.joins("JOIN (#{scoped_sql}) AS conditional_join ON conditional_join.#{primary_key} = #{ActsAsTaggableOn::Tagging.table_name}.taggable_id").
119 121
                                         group(group_columns).
120 122
                                         having(having)
121 123
         else

0 notes on commit 9385e17

Please sign in to comment.
Something went wrong with that request. Please try again.