Class: Wordpress::PostTag
Class Method Summary
collapse
Methods inherited from Taxonomy
#breadcrumbs, find_sti_class, #set_defaults, sti_name, #title
Methods inherited from WpBase
prefix_table_name
Class Method Details
.cloud ⇒ Object
3
4
5
6
7
|
# File 'app/models/wordpress/post_tag.rb', line 3
def self.cloud
tags_for_cloud = for_cloud.all
total_tags = tags_for_cloud.inject(0){|sum, t| sum += t.count}
tags_for_cloud.map{|t| {tag: t, size: 1.0 + (t.count / total_tags.to_f * 5)}}.sort_by{|sb| sb[:tag].slug}
end
|
.find_or_create(tag_name) ⇒ Object
9
10
11
12
|
# File 'app/models/wordpress/post_tag.rb', line 9
def self.find_or_create tag_name
raise "tag name can't be blank" if tag_name.blank?
joins(:term).where(wp_terms: {name: tag_name}).first || create!(term_id: Term.create!(name: tag_name).id)
end
|