Module: Skyline::Taggable
- Included in:
- MediaFile, Sections::ContentCollectionSection
- Defined in:
- lib/skyline/taggable.rb
Overview
Usage: class Model < ActiveRecord::Base
include Skyline::Taggable
end
1) Registers your model in the Skyline::Tag.taggable_models list
2) Gives your Model the following interface:
class Model < ActiveRecord::Base
has_many :associated_tags, :class_name => "Skyline::AssociatedTag", :as => "taggable"
has_many :tags, :through => :associated_tags, :class_name => "Skyline::Tag"
named_scope :with_tags () (scope to return items that have at least one of the supplied; or all if no are passed)
def
def (str)
def
end
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #available_tags ⇒ Object
- #clone_with_associated_tags ⇒ Object
- #raw_tags ⇒ Object
- #raw_tags=(str) ⇒ Object
Instance Method Details
#available_tags ⇒ Object
59 60 61 |
# File 'lib/skyline/taggable.rb', line 59 def self.class. end |
#clone_with_associated_tags ⇒ Object
63 64 65 66 67 |
# File 'lib/skyline/taggable.rb', line 63 def returning do |clone| clone. = self..collect{|at| at.clone } end end |
#raw_tags ⇒ Object
45 46 47 |
# File 'lib/skyline/taggable.rb', line 45 def self..collect{|t| t.tag}.join(" ") end |
#raw_tags=(str) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/skyline/taggable.rb', line 49 def (str) self..clear if str.present? str.split.each do |t| tag = Skyline::Tag.find_or_create_by_taggable_type_and_tag(self.tag_taggable_type, t) self. << tag unless self..include?(tag) end end end |