Sha256: 2612dc1429290d4bd2559d429cf08fad0a18b0006c8f77b42cb11e4df26ab1df
Contents?: true
Size: 831 Bytes
Versions: 22
Compression:
Stored size: 831 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: 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
22 entries across 22 versions & 2 rubygems