Module: Cms::Behaviors::Taggable::InstanceMethods
- Defined in:
- lib/cms/behaviors/taggable.rb
Instance Method Summary collapse
Instance Method Details
#save_tags ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cms/behaviors/taggable.rb', line 44 def = tag_list.to_s.split(self.class.tag_separator).map{|t| Cms::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
37 38 39 |
# File 'lib/cms/behaviors/taggable.rb', line 37 def tag_list @tag_list ||= .reload.map(&:name).join(self.class.tag_separator) end |
#tag_list=(tag_names) ⇒ Object
40 41 42 43 |
# File 'lib/cms/behaviors/taggable.rb', line 40 def tag_list=(tag_names) changed_attributes["tag_list"] = tag_list unless @tag_list == tag_names @tag_list = tag_names end |