use to_param (and change method to name accordingly)

- exclude Rack::Test::UploadedFile to pass existing tests. Are there any
  other types we're missing?
This commit is contained in:
David Chelimsky
2011-05-22 08:11:54 -04:00
parent 9277e72a3c
commit 3f0c71c852

View File

@@ -395,25 +395,25 @@ module ActionController
end
alias xhr :xml_http_request
def stringify_values(hash_or_array_or_value)
def paramify_values(hash_or_array_or_value)
case hash_or_array_or_value
when Hash
hash_or_array_or_value.each do |key, value|
hash_or_array_or_value[key] = stringify_values(value)
hash_or_array_or_value[key] = paramify_values(value)
end
when Array
hash_or_array_or_value.map {|i| stringify_values(i)}
when Numeric, Symbol
hash_or_array_or_value.to_s
else
hash_or_array_or_value.map {|i| paramify_values(i)}
when Rack::Test::UploadedFile
hash_or_array_or_value
else
hash_or_array_or_value.to_param
end
end
def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
# Ensure that numbers and symbols passed as params are converted to
# strings, as is the case when engaging rack.
stringify_values(parameters)
# proper params, as is the case when engaging rack.
paramify_values(parameters)
# Sanity check for required instance variables so we can give an
# understandable error message.