Forum: Ruby on Rails How to use redirect_to :action => 'something', params

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nikos D. (Guest)
on 2007-07-31 17:03
(Received via mailing list)
Hi there. I wanted to redirect to some page and at the same time keep
the parameters that arrived on the current request so i wrote the
following code:

redirect_to :action => 'some_action_here', params

Although it is a hash (the params) and a valid one, it doesn't work. I
assume it expects something like

redirect_to :action => 'some_actio_here', {:param1 =>
'something', :param2 => 'something else' }

but i don't want to hard code it. I want to resend all the params...

Any ideas???
Shandy N. (Guest)
on 2007-07-31 18:49
You want to assign the parameters on that page into a hash, for example,
lets say you have a whole bunch of fields that are related to user info,
you could say:

redirect_to :action => 'something', :user => params[:user]

then you use the :user hash to pick at all the variables in the next
page. So if you have multiple forms on the same page all containing
different types of info, you just follow the same format only seperated
by ','. Hope this helps,

~S
Nikos D. (Guest)
on 2007-07-31 19:53
(Received via mailing list)
Thanks for your interest but i figured out how to do what i wanted:

redirect_to params.merge({:action => 'something'})

So all of the params stayed untouched for the next controller/
action :)

Thanks a lot again for your interest!

On Jul 31, 5:49 pm, Shandy N. <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.