Created
October 25, 2011 15:58
-
-
Save JakeAustwick/1313254 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment