Class: Comment

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

Instance Method Summary collapse

Instance Method Details

#before_saveObject



7
8
9
10
11
12
13
14
15
16
17
# File 'app/models/comment.rb', line 7

def before_save
  self.posted_by = 'Anonymous' if self.posted_by.nil? or self.posted_by.empty?
  self.subject   = '' if self.subject.nil?
  
  # Scrub up
  self.posted_by = CGI.escapeElement self.posted_by, 'script'
  self.subject   = CGI.escapeElement self.subject, 'script'
  self.body      = CGI.escapeElement self.body, 'script'
  
  self.rendered  = RedCloth.new(self.body).to_html
end