Module: Cms::Behaviors::Taggable::InstanceMethods
- Defined in:
- lib/cms/behaviors/taggable.rb
Instance Method Summary collapse
Instance Method Details
#save_tags ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cms/behaviors/taggable.rb', line 42 def = tag_list.to_s.split(self.class.tag_separator).map{|t| Tag.find_or_create_by_name(t.strip) } taggings.each do |tg| if .include?(tg.tag) .delete(tg.tag) else tg.destroy end end .each{|t| taggings.create(:tag => t, :taggable => self) } self.tag_list = nil end |
#tag_list ⇒ Object
35 36 37 |
# File 'lib/cms/behaviors/taggable.rb', line 35 def tag_list @tag_list ||= .reload.map(&:name).join(self.class.tag_separator) end |
#tag_list=(tag_names) ⇒ Object
38 39 40 41 |
# File 'lib/cms/behaviors/taggable.rb', line 38 def tag_list=(tag_names) changed_attributes["tag_list"] = tag_list unless @tag_list == tag_names @tag_list = tag_names end |