There are several questions, which explain how to pass request parameters to a redirect (this and this). However, I don't see from their answers how to insert new parameters that weren's in the request already.
I want to do something like:
get '/models', to: redirect('/models?foo=bar&baz=qux')
When I do this, I get:
Redirected to http://localhost:3000/models
Completed 302 Found in 2704ms (ActiveRecord: 140.6ms)
Started GET "/models" for 127.0.0.1 at 2014-11-18 16:51:31 +0200
Started GET "/models?foo=bar&baz=qux" for 127.0.0.1 at 2014-11-18 16:51:31 +0200
Started GET "/models?foo=bar&baz=qux" for 127.0.0.1 at 2014-11-18 16:51:31 +0200
Started GET "/models?foo=bar&baz=qux" for 127.0.0.1 at 2014-11-18 16:51:31 +0200
Started GET "/models?foo=bar&baz=qux" for 127.0.0.1 at 2014-11-18 16:51:31 +0200
and eventually This page has a redirect loop
.
Probably I shouldn't do this in the routes.rb, but assign default values of the index action in the controller, but the thing is I want my page to have ?foo=bar&baz=qux
appended to the URL. How can I do this?