문제

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?

도움이 되었습니까?

해결책

Try,

request.params.clear
request.params[:new] = "hi"
p request.params
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top