ruby-on-railsrubyrackrackup

Replace the params in the Rack middleware


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?


Solution

  • Try,

    request.params.clear
    request.params[:new] = "hi"
    p request.params