Sha256: cb0b32c3cb7b0a02d0a7a78d6688bbd5cef18a21f6661a2a16d64d1e964671dc

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

Stored size: 924 Bytes

Contents

unless defined? ActiveModel::ForbiddenAttributesProtection
  module ActiveModel
    # Raised when forbidden attributes are used for mass assignment.
    #
    #   class Person < ActiveRecord::Base
    #   end
    #
    #   params = ActionController::Parameters.new(name: 'Bob')
    #   Person.new(params)
    #   # => ActiveModel::ForbiddenAttributesError
    #
    #   params.permit!
    #   Person.new(params)
    #   # => #<Person id: nil, name: "Bob">
    class ForbiddenAttributesError < StandardError
    end

    module ForbiddenAttributesProtection # :nodoc:
      protected
        def sanitize_for_mass_assignment(attributes)
          if attributes.respond_to?(:permitted?) && !attributes.permitted?
            raise ActiveModel::ForbiddenAttributesError
          else
            attributes
          end
        end
        alias :sanitize_forbidden_attributes :sanitize_for_mass_assignment
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
neo4j_legacy-7.2.0.2 lib/backports/active_model/forbidden_attributes_protection.rb
neo4j_legacy-7.2.0.1 lib/backports/active_model/forbidden_attributes_protection.rb