user984621
user984621

Reputation: 48443

Rails 3, acts-as-taggable-on gem - how to get the most used tags?

I use acts-as-taggable-on gem and would like to fetch 5 most used tags, how could I fetch them?

Upvotes: 1

Views: 552

Answers (1)

Panagiotis Petridis
Panagiotis Petridis

Reputation: 164

I think that your controller must be:

class PostController < ApplicationController
    def tag_cloud
        @tags = Post.tag_counts_on(:tags).limit(5).order('count desc')
    end
end

Upvotes: 4

Related Questions