module Lanes::Concerns::SanitizeFields::ClassMethods
Public Instance Methods
sanitize_fields(*fields)
click to toggle source
Remove invalid HTML from fields before save by using the “sanitize” gem's Sanitize.fragment method.
Defaults to removing all HTML, but a valid Sanitize::Config hash can be specified as well.
# File lib/lanes/concerns/sanitize_fields.rb, line 16 def sanitize_fields(*fields) options = fields.extract_options! using = options[:using] || {} before_save do fields.each do |field| value = read_attribute(field) unless value.blank? write_attribute(field, Sanitize.fragment(sanitized,using)) end end end end