Module: ActiveRecord::Acts::Taggable::SingletonMethods

Defined in:
vendor/plugins/blacklight/lib/taggable_pagination.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) paginate_by_tag(tag, options = {}, find_options = {})



14
15
16
17
18
19
20
21
22
23
24
25
# File 'vendor/plugins/blacklight/lib/taggable_pagination.rb', line 14

def paginate_by_tag(tag, options = {}, find_options = {})
  page, per_page, total = wp_parse_options(options)#WillPaginate::Finder::ClassMethods.send(:wp_parse_options, options)
  offset = (page.to_i - 1) * per_page
  find_options.merge!(:offset => offset, :limit => per_page.to_i)
  items = tag ? find_tagged_with(tag, find_options) : paginate(options)
  options.delete :page
  options.delete :per_page
  count = tag ? tagging_counts(tag) : self.count(options)
  returning WillPaginate::Collection.new(page, per_page, count) do |p|
    p.replace items
  end
end

- (Object) tagging_counts(tag)



10
11
12
# File 'vendor/plugins/blacklight/lib/taggable_pagination.rb', line 10

def tagging_counts(tag)
  count_by_sql("select count(*) FROM tags, taggings WHERE " + sanitize_sql(['tags.name = ? AND tags.id = taggings.tag_id AND taggings.taggable_type = ?', tag, name]))
end