Sha256: 769d2a37b546b2420492558c854b2d8cefdf23498dd694fe0bfca85319cc4ac6

Contents?: true

Size: 912 Bytes

Versions: 42

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

module ActiveModel
  # = Active \Model \ForbiddenAttributesError
  #
  # 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:
    private
      def sanitize_for_mass_assignment(attributes)
        if attributes.respond_to?(:permitted?)
          raise ActiveModel::ForbiddenAttributesError if !attributes.permitted?
          attributes.to_h
        else
          attributes
        end
      end
      alias :sanitize_forbidden_attributes :sanitize_for_mass_assignment
  end
end

Version data entries

42 entries across 42 versions & 6 rubygems

Version Path
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/activemodel-7.1.3.4/lib/active_model/forbidden_attributes_protection.rb
activemodel-8.0.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-8.0.0.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-7.2.2.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-7.1.5.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-8.0.0 lib/active_model/forbidden_attributes_protection.rb
activemodel-7.2.2 lib/active_model/forbidden_attributes_protection.rb
activemodel-7.1.5 lib/active_model/forbidden_attributes_protection.rb
activemodel-8.0.0.rc2 lib/active_model/forbidden_attributes_protection.rb
activemodel-7.2.1.2 lib/active_model/forbidden_attributes_protection.rb
activemodel-7.1.4.2 lib/active_model/forbidden_attributes_protection.rb
activemodel-8.0.0.rc1 lib/active_model/forbidden_attributes_protection.rb
activemodel-7.2.1.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-7.1.4.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-8.0.0.beta1 lib/active_model/forbidden_attributes_protection.rb
omg-activemodel-8.0.0.alpha9 lib/active_model/forbidden_attributes_protection.rb
omg-activemodel-8.0.0.alpha8 lib/active_model/forbidden_attributes_protection.rb
omg-activemodel-8.0.0.alpha7 lib/active_model/forbidden_attributes_protection.rb
omg-activemodel-8.0.0.alpha4 lib/active_model/forbidden_attributes_protection.rb
omg-activemodel-8.0.0.alpha3 lib/active_model/forbidden_attributes_protection.rb