Created
January 22, 2009 22:43
-
-
Save billturner/50765 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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