Created
October 4, 2019 21:43
-
-
Save jcypret/06b0f72d88fcd56ee6790f1e8627f575 to your computer and use it in GitHub Desktop.
Recursively marks ActionController::Parameters as permitted
This file contains hidden or 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
def deep_permit(args) | |
case args | |
when ActionController::Parameters | |
args.to_unsafe_hash.deep_symbolize_keys | |
when Hash | |
args.symbolize_keys.transform_values(&method(:deep_permit)) | |
when Array | |
args.map(&method(:deep_permit)) | |
else | |
args | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment