module ActionDispatch::Http::UnderscoreParams
Overrides the default params method on ActionDispatch::Request to underscore all keys (request.params is aliased to parameters)
Should be included into ActionDispatch::Request after the standard Rails modules
Public Instance Methods
parameters()
click to toggle source
Processes parameters by underscoring all hash keys
Calls superclass method
# File lib/underscore_params/action_dispatch/http/underscore_params.rb, line 15 def parameters underscore_keys super end
Private Instance Methods
underscore_key(val)
click to toggle source
# File lib/underscore_params/action_dispatch/http/underscore_params.rb, line 38 def underscore_key(val) val.to_s.underscore end
underscore_keys(value)
click to toggle source
Underscores all key values in both Hashes and Hashes in arrays. Other values are not modified
@param value [Object] The value to be processed
# File lib/underscore_params/action_dispatch/http/underscore_params.rb, line 27 def underscore_keys(value) case value when Array value.map { |v| underscore_keys(v) } when Hash Hash[value.map { |k, v| [underscore_key(k), underscore_keys(v)] }] else value end end