ruby: 2.0.0p0, rails: 3.2.13 , acts-as-taggable-on 2.4.1
正在使用acts_as_taggable_on
来打标签,现在我获取到每个标签名字及对应的数量
2.0.0p0 :049 > Question.tag_counts
(0.3ms) SELECT questions.id FROM "questions"
ActsAsTaggableOn::Tag Load (0.3ms) SELECT tags.*, taggings.tags_count AS count FROM "tags" JOIN (SELECT taggings.tag_id, COUNT(taggings.tag_id) AS tags_count FROM "taggings" INNER JOIN questions ON questions.id = taggings.taggable_id WHERE (taggings.taggable_type = 'Question' AND taggings.context = 'tags') AND (taggings.taggable_id IN(10,17,18,22,23,24,26,27,28,29,30,31,32)) GROUP BY taggings.tag_id HAVING COUNT(taggings.tag_id) > 0) AS taggings ON taggings.tag_id = tags.id
这个貌似只返回了 tag_id 和 tag name。求指导。