mirror of
https://github.com/github/rails.git
synced 2026-02-15 08:36:04 -05:00
Be sure to look at array elements when dasherizing keys of a formatted request
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3904 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -80,15 +80,17 @@ 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
|
||||
case params.class.to_s
|
||||
when "Hash"
|
||||
params.inject({}) do |h,(k,v)|
|
||||
h[k.to_s.tr("-", "_")] = dasherize_keys(v)
|
||||
h
|
||||
end
|
||||
when "Array"
|
||||
params.map { |v| dasherize_keys(v) }
|
||||
else
|
||||
params
|
||||
end
|
||||
end
|
||||
|
||||
# Splits the given key into several pieces. Example keys are 'name', 'person[name]',
|
||||
|
||||
Reference in New Issue
Block a user