Question

I have a app in rails 2.3 and want to have a middleware which can replace the entire params hash with a new hash

i would be having the rack request object in my middleware so when i do request.params it returns me some hash say {"y" => "c", "x" => "4"} now my requirement is i want to delete everything and create a request.params object as {"z" => "t"} i just want to replace the hash i don't see any setter method available to replace the hash is there any way to do this?

Was it helpful?

Solution

Try,

request.params.clear
request.params[:new] = "hi"
p request.params
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top