Module | ActiveRecord::Acts::Taggable::SingletonMethods
In: | lib/acts_as_taggable_on_steroids_will_paginate.rb

### Methods

paginate_by_tag tagging_counts

### Public Instance methods

paginate_by_tag(tags, options = {})

paginate a call to find_tagged_with tags are the tags to find options is the option to use for pagination (:page, :per_page) and for find_tagged_with

[Source]

        # File lib/acts_as_taggable_on_steroids_will_paginate.rb, line 20
    20:         def paginate_by_tag(tags, options = {})
    21:           page, per_page, total = wp_parse_options(options)
    22:           offset = (page.to_i - 1) * per_page
    23:           options = options.delete_if {|k, v| [:page, :per_page, :total_entries].include?(k)}
    24:           options.merge!(:offset => offset, :limit => per_page.to_i)
    25:           items = find_tagged_with(tags, options)
    26:           tags_for_count = tags.collect {|t| "\'#{t}\'"}.join(', ')
    27:           count = tagging_counts(tags_for_count, options)
    28:           returning WillPaginate::Collection.new(page, per_page, count) do |p|
    29:             p.replace items
    30:           end
    31:         end

tagging_counts(comma_separated_tags, options={})

Return the number of time this class has been tagged with this tag

[Source]

        # File lib/acts_as_taggable_on_steroids_will_paginate.rb, line 6
     6:         def tagging_counts(comma_separated_tags, options={})
     7:           # Hack!
     8:           conditions = " "
     9:           conditions << "(#{options[:conditions]}) AND " if options[:conditions]
    10:           taggable_table = name.tableize
    11:           count_by_sql("select count(distinct taggable_id)
    12:             FROM tags, taggings, #{taggable_table}
    13:             WHERE #{conditions} "  + sanitize_sql(["(#{Tag.sanitized_name_columns.collect {|c| "#{c} IN (#{comma_separated_tags})"}.join(' OR ')})
    14:               AND tags.id = taggings.tag_id AND taggings.taggable_type = :name AND #{taggable_table}.id=taggings.taggable_id", {:name => name}]))
    15:         end

[Validate]