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 43
43: def encode_params(params)
44: return params unless "ruby".encoding_aware?
45:
46: if params.is_a?(String)
47: return params.force_encoding("UTF-8").encode!
48: elsif !params.is_a?(Hash)
49: return params
50: end
51:
52: params.each do |k, v|
53: case v
54: when Hash
55: encode_params(v)
56: when Array
57: v.map! {|el| encode_params(el) }
58: else
59: encode_params(v)
60: end
61: end
62: end
Convert nested Hash to HashWithIndifferentAccess
# File lib/action_dispatch/http/parameters.rb, line 65
65: def normalize_parameters(value)
66: case value
67: when Hash
68: h = {}
69: value.each { |k, v| h[k] = normalize_parameters(v) }
70: h.with_indifferent_access
71: when Array
72: value.map { |e| normalize_parameters(e) }
73: else
74: value
75: end
76: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.