Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 29 lines (27 sloc) 0.807 kb
a8f6d5c Guillermo Iguaran Integrate ActiveModel::ForbiddenAttributesProtection from StrongParamete...
guilleiguaran authored
1 module ActiveModel
1e56f1f Francesco Rodríguez update AMo::ForbiddenAttributesError documentation [ci skip]
frodsan authored
2 # Raised when forbidden attributes are used for mass assignment.
3 #
4 # class Person < ActiveRecord::Base
5 # end
6 #
7 # params = ActionController::Parameters.new(name: 'Bob')
8 # Person.new(params)
9 # # => ActiveModel::ForbiddenAttributesError
10 #
11 # params.permit!
12 # Person.new(params)
13 # # => #<Person id: nil, name: "Bob">
1fa4f92 Guillermo Iguaran Rename ForbiddenAttributes exception to ForbiddenAttributesError
guilleiguaran authored
14 class ForbiddenAttributesError < StandardError
a8f6d5c Guillermo Iguaran Integrate ActiveModel::ForbiddenAttributesProtection from StrongParamete...
guilleiguaran authored
15 end
16
6783c3f Francesco Rodríguez change AMo::ForbiddenAttributesProtection#sanitize_for_mass_assignment t...
frodsan authored
17 module ForbiddenAttributesProtection # :nodoc:
18 protected
72f5085 Aaron Patterson rm dead code
tenderlove authored
19 def sanitize_for_mass_assignment(attributes)
6783c3f Francesco Rodríguez change AMo::ForbiddenAttributesProtection#sanitize_for_mass_assignment t...
frodsan authored
20 if attributes.respond_to?(:permitted?) && !attributes.permitted?
21 raise ActiveModel::ForbiddenAttributesError
22 else
23 attributes
24 end
a8f6d5c Guillermo Iguaran Integrate ActiveModel::ForbiddenAttributesProtection from StrongParamete...
guilleiguaran authored
25 end
306dc1a Rafael Mendonça França Check attributes passed to create_with and where
rafaelfranca authored
26 alias :sanitize_forbidden_attributes :sanitize_for_mass_assignment
a8f6d5c Guillermo Iguaran Integrate ActiveModel::ForbiddenAttributesProtection from StrongParamete...
guilleiguaran authored
27 end
28 end
Something went wrong with that request. Please try again.