Returns both GET and POST parameters in a single hash.
# File lib/action_dispatch/http/parameters.rb, line 8 8: def parameters 9: @env["action_dispatch.request.parameters"] ||= begin 10: params = request_parameters.merge(query_parameters) 11: params.merge!(path_parameters) 12: encode_params(params).with_indifferent_access 13: end 14: end
Returns a hash with the parameters used to form the path of the request. Returned hash keys are strings:
{'action' => 'my_action', 'controller' => 'my_controller'}
See symbolized_path_parameters for symbolized keys.
# File lib/action_dispatch/http/parameters.rb, line 34 34: def path_parameters 35: @env["action_dispatch.request.path_parameters"] ||= {} 36: end
The same as path_parameters with explicitly symbolized keys.
# File lib/action_dispatch/http/parameters.rb, line 24 24: def symbolized_path_parameters 25: @symbolized_path_params ||= path_parameters.symbolize_keys 26: end
TODO: Validate that the characters are UTF-8. If they aren’t, you’ll get a weird error down the road, but our form handling should really prevent that from happening
# File lib/action_dispatch/http/parameters.rb, line 47 47: def encode_params(params) 48: return params unless "ruby".encoding_aware? 49: 50: if params.is_a?(String) 51: return params.force_encoding("UTF-8").encode! 52: elsif !params.is_a?(Hash) 53: return params 54: end 55: 56: params.each do |k, v| 57: case v 58: when Hash 59: encode_params(v) 60: when Array 61: v.map! {|el| encode_params(el) } 62: else 63: encode_params(v) 64: end 65: end 66: end
Convert nested Hash to HashWithIndifferentAccess
# File lib/action_dispatch/http/parameters.rb, line 69 69: def normalize_parameters(value) 70: case value 71: when Hash 72: h = {} 73: value.each { |k, v| h[k] = normalize_parameters(v) } 74: h.with_indifferent_access 75: when Array 76: value.map { |e| normalize_parameters(e) } 77: else 78: value 79: end 80: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.