Sha256: ea6b66cac6ddef99a96df93a6e779a4332e56689fb8480b51d87a1ca5082af74

Contents?: true

Size: 807 Bytes

Versions: 94

Compression:

Stored size: 807 Bytes

Contents

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

Version data entries

94 entries across 89 versions & 9 rubygems

Version Path
activemodel-4.2.11.3 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.11.2 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.11.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.11 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.10 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.10.rc1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.9 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.9.rc2 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.9.rc1 lib/active_model/forbidden_attributes_protection.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activemodel-4.2.8/lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.8 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.8.rc1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.7.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.7 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.16 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.16.rc1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.7.rc1 lib/active_model/forbidden_attributes_protection.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activemodel-4.2.6/lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.15 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.2.6 lib/active_model/forbidden_attributes_protection.rb