Sha256: e084038ccaaf39117cc6cb2c6c0cd1e8e01f2b79fe7b3d94a184ac6c4c341f67
Contents?: true
Size: 1.02 KB
Versions: 9
Compression:
Stored size: 1.02 KB
Contents
require 'sanitize' module Hippo module Concerns # @see ClassMethods module SanitizeFields extend ActiveSupport::Concern module ClassMethods # 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. 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 end end end end
Version data entries
9 entries across 9 versions & 1 rubygems