Skip to content

Instantly share code, notes, and snippets.

@parndt
Created July 16, 2010 06:05
Show Gist options
  • Save parndt/478001 to your computer and use it in GitHub Desktop.
Save parndt/478001 to your computer and use it in GitHub Desktop.
before_save :normalise_text_fields
protected
def normalise_text_fields
unless self.body.blank? or self.body =~ /^\</
self.body = "<p>#{self.body.gsub("\r\n\r\n", "</p><p>").gsub("\r\n", "<br/>")}</p>"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment