I have a post model that has many tags through taggings.
let’s say:
@posts = Post.followed_by(@user)
I want to get all tags of @posts.
I can do it with something like:
@posts.each do |post|
@tags << post.tags
end
how can I do it in a more efficient way?
Try this:
If
@postsis a relation (not an array), you can simplify your query: