Sha256: 515e7139207abde698ebc5eb59ebc32e344312851ea2b0a24c9ad3804a69db1f

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

module ActiveModel
  module SuppressForbiddenAttributes
    def sanitize_for_mass_assignment(*options)
      new_attributes = options.first
      if new_attributes.respond_to?(:permitted?) && !new_attributes.permitted?
        ParamsPatrol.handle(error: ActiveModel::ForbiddenAttributes.new,
                            parameters: options.try(:first),
                            cgi_data: ENV.to_hash)
        # help surface these kinds of issues in the test env
        # raise(ActiveModel::ForbiddenAttributes) if Rails.env.test?
      end

      ActiveModel::MassAssignmentSecurity.instance_method(:sanitize_for_mass_assignment).bind(self).call(*options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
params_patrol-0.1.0 lib/active_model/suppress_forbidden_attributes.rb