Sha256: a995fb63830dc38bf07da8e3668ba22ac07567bb80df2d532c6c3c8fddca82e7

Contents?: true

Size: 734 Bytes

Versions: 33

Compression:

Stored size: 734 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
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
activemodel-4.1.4 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.8 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.3 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.7 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.6 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.2 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.2.rc3 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.6.rc3 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.2.rc2 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.6.rc2 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.2.rc1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.6.rc1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.5 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.0 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.0.rc2 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.4 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.4.rc1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.1.0.rc1 lib/active_model/forbidden_attributes_protection.rb
activemodel-4.0.3 lib/active_model/forbidden_attributes_protection.rb