Class: ActsAsTaggableOn::Tag
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActsAsTaggableOn::Tag
- Defined in:
- app/models/acts_as_taggable_on/tag.rb
Overview
require_dependency ActsAsTaggableOn::Engine.config.root.join(‘lib’, ‘acts_as_taggable_on’, ‘tag.rb’).to_s
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.default_per_page ⇒ Object
15 16 17 |
# File 'app/models/acts_as_taggable_on/tag.rb', line 15 def default_per_page 25 end |
.popular(limit = 20, type = nil) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/models/acts_as_taggable_on/tag.rb', line 6 def popular(limit = 20, type = nil) if type == nil ActsAsTaggableOn::Tag.most_used(limit) else klass = Object.const_get type klass.tag_counts.most_used(limit) end end |
Instance Method Details
#related_tags(limit = 10) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/acts_as_taggable_on/tag.rb', line 26 def (limit = 10) taggables = self.taggings.limit(10).to_a.collect{|t| t.taggable }.compact tagging_ids = taggables.map{|t| t.taggings.limit(10).map(&:id) }.flatten.uniq return [] if tagging_ids.blank? ActsAsTaggableOn::Tag.where("tags.id != '#{self.id}'") .joins(:taggings) .where({:taggings => {:id => tagging_ids }}) .order("taggings_count DESC") .limit(limit) end |
#to_param ⇒ Object
21 22 23 |
# File 'app/models/acts_as_taggable_on/tag.rb', line 21 def to_param URI.escape(URI.escape(self.name), /[\/.?#]/) end |