Skip to content

Instantly share code, notes, and snippets.

@jcypret
Created October 4, 2019 21:43
Show Gist options
  • Save jcypret/06b0f72d88fcd56ee6790f1e8627f575 to your computer and use it in GitHub Desktop.
Save jcypret/06b0f72d88fcd56ee6790f1e8627f575 to your computer and use it in GitHub Desktop.
Recursively marks ActionController::Parameters as permitted
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