Class: Tag

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/tag.rb

Instance Method Summary collapse

Instance Method Details

#before_saveObject



7
8
9
# File 'app/models/tag.rb', line 7

def before_save
  self.tag = CGI.escapeElement(self.tag, 'script')
end


11
12
13
14
15
# File 'app/models/tag.rb', line 11

def related_tags
  related_tags = []
  self.posts.each { |p| p.tags.each { |tt| related_tags << tt } }
  related_tags.uniq.select { |t| t.tag != self.tag }
end