diff options
author | Jamis Buck <jamis@37signals.com> | 2006-03-15 21:46:41 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-03-15 21:46:41 +0000 |
commit | 2429074075b08b219f4dbbe8f6d08598c1d67878 (patch) | |
tree | ef5fd183f7e5a17fe8de9d613b4bc0be325454c3 /actionpack/lib/action_controller/cgi_ext | |
parent | 6c95e9b14697a9527ab761d1a084f6bc61af56b9 (diff) | |
download | rails-2429074075b08b219f4dbbe8f6d08598c1d67878.tar.gz rails-2429074075b08b219f4dbbe8f6d08598c1d67878.tar.bz2 rails-2429074075b08b219f4dbbe8f6d08598c1d67878.zip |
Underscore dasherized keys in formatted requests
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3878 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/cgi_ext')
-rwxr-xr-x | actionpack/lib/action_controller/cgi_ext/cgi_methods.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb index f092a41d47..cd70836c6e 100755 --- a/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb +++ b/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb @@ -71,7 +71,7 @@ class CGIMethods #:nodoc: { node.node_name => node } end - params || {} + dasherize_keys(params || {}) rescue Object => e { "exception" => "#{e.message} (#{e.class})", "backtrace" => e.backtrace, "raw_post_data" => raw_post_data, "format" => mime_type } @@ -79,6 +79,18 @@ class CGIMethods #:nodoc: private + def self.dasherize_keys(params) + case params.class.to_s + when "Hash" + params.inject({}) do |h,(k,v)| + h[k.tr("-", "_")] = dasherize_keys(v) + h + end + else + params + end + end + # Splits the given key into several pieces. Example keys are 'name', 'person[name]', # 'person[name][first]', and 'people[]'. In each instance, an Array instance is returned. # 'person[name][first]' produces ['person', 'name', 'first']; 'people[]' produces ['people', ''] |