Module: Cms::Behaviors::Taggable::MacroMethods

Defined in:
lib/cms/behaviors/taggable.rb

Instance Method Summary collapse

Instance Method Details

#is_taggable(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cms/behaviors/taggable.rb', line 11

def is_taggable(options={})
  @is_taggable = true
  @tag_separator = options[:separator] || " "
  
  has_many :taggings, :as => :taggable, :class_name => 'Cms::Tagging'
  has_many :tags, :through => :taggings, :order => "#{Cms::Tag.table_name}.name", :class_name => 'Cms::Tag'          
  
  scope :tagged_with, lambda{|t| {:include => {:taggings => :tag}, :conditions => ["#{Cms::Tag.table_name}.name = ?", t]} }

  after_save :save_tags          
            
  extend ClassMethods
  include InstanceMethods

  attr_accessible :tag_list
end

#taggable?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/cms/behaviors/taggable.rb', line 8

def taggable?
  !!@is_taggable
end