Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Comment < ActiveRecord::Base
- include Sanitize
- belongs_to :picture
- validates :name, :presence => true
- validates :comment, :presence => true, :length => { :in => 5..300 }
- before_save :strip_html
- private
- def strip_html
- self.name = Sanitize.clean(self.name) # Strips all HTML
- self.comment = Sanitize.clean(self.comment, Sanitize::Config::BASIC) # Add nofollow to avoid spam, and allows basic formatting.
- end
- end
Add Comment
Please, Sign In to add comment