Search code examples
ruby-on-railsrubyacts-as-taggable-on

acts_as_taggable_on Tag_counts_on() method


I am currently having some trouble with the Model.tag_counts_on() method in the acts_as_taggable_on plugin in Rails. I can't find real documentation on the method and I want to know more about the parameters it accepts. I am trying to get tag counts on a subset of tags, not the whole set of tags on my application, how would I go about doing this?


Solution

  • Assuming that you are using mbleigh/acts-as-taggable-on

    This is the master branch of the gem in which the method appears in.

    I would examine the conditions and on parameters.

    def tag_counts_on(context, options = {})
      all_tag_counts(options.merge({:on => context.to_s}))
    end
    
    ##
    # Calculate the tag counts for all tags.
    #
    # @param [Hash] options Options:
    # * :start_at   - Restrict the tags to those created after a certain time
    # * :end_at     - Restrict the tags to those created before a certain time
    # * :conditions - A piece of SQL conditions to add to the query
    # * :limit      - The maximum number of tags to return
    # * :order      - A piece of SQL to order by. Eg 'tags.count desc' or 'taggings.created_at desc'
    # * :at_least   - Exclude tags with a frequency less than the given value
    # * :at_most    - Exclude tags with a frequency greater than the given value
    # * :on         - Scope the find to only include a certain context
    def all_tag_counts(options = {})..end