Suppose you have a url
localhost:3000?a=1
and in the request, you also have a post parameter
a=2
What wou
Rails uses Rack::Request for HTTP requests. However, it redefines the Rack params method in ActionDispatch::Http::Parameters (via an alias).
This params method, which returns request parameters, is implemented as:
# Returns both GET and POST \parameters in a single hash.
def parameters
@env["action_dispatch.request.parameters"] ||= begin
params = request_parameters.merge(query_parameters)
params.merge!(path_parameters)
encode_params(params).with_indifferent_access
end
end
alias :params :parameters
Note the aliased parameters method.
Unless redefined, parameters from the query string will overwrite parameters from the POST body.