Created
December 10, 2015 16:34
-
-
Save dv/973f7361733091828c6e to your computer and use it in GitHub Desktop.
For when you're in between mass-assignment and strong-params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveModel | |
module MassAssignmentSecurity | |
# Original source: https://github.com/rails/protected_attributes/blob/0421e825911b05a77c6521171b43070c9e6c4b35/lib/active_model/mass_assignment_security.rb#L350 | |
def sanitize_for_mass_assignment(attributes, role = nil) #:nodoc: | |
if attributes.respond_to?(:permitted?) && _uses_mass_assignment_security | |
_mass_assignment_sanitizer.sanitize(self.class, attributes, mass_assignment_authorizer(role)) | |
else | |
sanitize_forbidden_attributes(attributes) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment