Guest User

Untitled

a guest
Aug 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class Comment < ActiveRecord::Base
  2. include Sanitize
  3. belongs_to :picture
  4.  
  5. validates :name, :presence => true
  6. validates :comment, :presence => true, :length => { :in => 5..300 }
  7.  
  8. before_save :strip_html
  9.  
  10. private
  11.  
  12. def strip_html
  13. self.name = Sanitize.clean(self.name) # Strips all HTML
  14. self.comment = Sanitize.clean(self.comment, Sanitize::Config::BASIC) # Add nofollow to avoid spam, and allows basic formatting.
  15. end
  16.  
  17. end
Add Comment
Please, Sign In to add comment