public
Description: This contains various plugins for Feather
Clone URL: git://github.com/eldiablo/feather-plugins.git
Search Repo:
Click here to lend your support to: feather-plugins and make a donation at www.pledgie.com !
whoisjake (author)
Sat May 10 14:38:11 -0700 2008
commit  32044e0cf46643fb3bbaddc4539c460f72df8a28
tree    6b2fb5aa28b4105fc9657dc7819e26eaf31d0413
parent  8a23772d42e56d48cd849354e4f03bf3514c05f8
100644 23 lines (21 sloc) 0.686 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
##
# Reopen the article model and wang in the stuff we need
class Article
  # We define this tags attribute so when the form posts, the params for tags get set, and we can subsequently access it later on
  attr_accessor :tag_list
  has_many :taggings
 
  def create_tags
    return if @tag_list.nil? || @tag_list.empty?
    # Wax all the existing taggings
    self.taggings.each {|t| t.destroy! }
    @tag_list.split(",").each do |t|
      unless t.empty?
        tag = Tag.find_or_create(:name => t.strip.downcase)
        Tagging.create(:article_id => self.id, :tag_id => tag.id)
      end
    end
  end
 
  def tags
    taggings.map { |tagging| tagging.tag.name }.join(", ")
  end
end