Skip to content

Instantly share code, notes, and snippets.

@billturner
Created January 22, 2009 22:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billturner/50765 to your computer and use it in GitHub Desktop.
Save billturner/50765 to your computer and use it in GitHub Desktop.
def assign_tags(tags)
tags.split(',').collect {|t| t.strip}.uniq.each do |tag|
thistag = Tag.first_or_create(:name => tag.downcase)
PostTagging.create(:post_id => self.id, :tag_id => thistag.id)
end
end
def update_tags(tags)
self.post_taggings.each { |tagging| tagging.destroy }
self.post_taggings.reload
tags.split(',').collect {|t| t.strip}.uniq.each do |tag|
thistag = Tag.first_or_create(:name => tag.downcase)
PostTagging.create(:post_id => self.id, :tag_id => thistag.id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment