Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using "tagged_with" together with "includes" #47

Open
manuelmeurer opened this issue Dec 23, 2012 · 0 comments
Open

Error when using "tagged_with" together with "includes" #47

manuelmeurer opened this issue Dec 23, 2012 · 0 comments

Comments

@manuelmeurer
Copy link
Contributor

I noticed an error when "tagged_with" is used together with "includes".
I added a failing test case here: krautcomputing/rocket_tag@e66410b0a9feac87a69aeb14bae90511847a3fcc

The error occurs quite deep in Active Record:

NoMethodError: undefined method `left' for :count:Symbol
# /Users/me/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/activerecord-3.2.6/lib/active_record/associations/alias_tracker.rb:64:in `block in initial_count_for'

It seems to have to do with using count in the subquery. See the full stack trace here: https://gist.github.com/4363280

SELECT "taggable_models".* FROM (SELECT count("tags"."id") AS tags_count, taggable_models.* FROM "taggable_models" INNER JOIN "taggings" ON "taggings"."taggable_id" = "taggable_models"."id" AND "taggings"."taggable_type" = 'TaggableModel' INNER JOIN "tags" ON "tags"."id" = "taggings"."tag_id" WHERE "tags"."name" IN ('foo') GROUP BY "taggable_models"."id", "taggable_models"."user_id", "taggable_models"."name", "taggable_models"."type", "taggable_models"."foo" ORDER BY tags_count desc) taggable_models

I will investigate further what may cause this error but all tips are appreciated! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant