I would like to create a URL where the request parameter p = 1 appears at the end of the URL, for example:
/path?foo=X&bar=Y&p=1
Is it possible to control the ordering of query parameters when creating URLs by:
url_for(params.merge({ p: page_num }))
?
Update:
I tried . It turns out that hashes are already ordered in Ruby 1.9, so the code in ActiveSupport::OrderedHash does not actually work. You can verify with Ruby 1.9 that the order is being saved:
>> h = {one: 1, two: 2, three: 3 } {:one=>1, :two=>2, :three=>3} >> f = h.except(:one) {:two=>2, :three=>3} >> f[:one] = 1 1 >> f {:two=>2, :three=>3, :one=>1}
However, url_for still sets the p parameter. It seems like any potential solution should decide how url_for the hash.
source share