Tag cloud of only specific posts in rails
Hi i am using acts_as_taggable in my rails app 2.3.11.
I have model User who can posts which has tags associated . So i am using like
@tags = User.find(:first).posts.tag_counts
to get the tags which will display using tag_cloud
Now the issue is , we have some fea开发者_运维问答ture which remove the some of the posts of the User based on some condition on the post type , NOW how can i get the tags of only those posts . The posts that i wanted i am keeping in @posts . But how to use the same ..
Please give some suggestions
Define a scope in post that defines the conditions based on the post type. Since, you have not mentioned the exact criteria..
class Post < ActiveRecord::Base
scope :specific_type, <?> #fill in with conditions for type of post
end
User.find(:first).posts.specific_type.tag_counts
精彩评论