Quick question:
>>
Group.first.resources.joins(:tags).group("tags.id").select("tags.id,
count(*)")
=> [#<Resource id: 1>, #<Resource id: 2>, #<Resource id:
3>,
#<Resource id: 4>, #<Resource id: 5>]
This results in the following (correct) query:
"SELECT tags.id, count(*) FROM "resources" INNER JOIN
"taggings" ON
"resources"."id" =
"taggings"."resource_id" INNER JOIN "tags" ON
"tags"."id" = "taggings"."tag_id" INNER
JOIN "group_resources" ON
"resources".id = "group_resources".resource_id WHERE
(("group_resources".group_id = 1)) GROUP BY tags.id"
I don''t want the Resources, I want the damn Tags. Any clues?
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.