How to use redirect_to :action => 'something', params


#1

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???


#2

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


#3

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 :slight_smile:

Thanks a lot again for your interest!

On Jul 31, 5:49 pm, Shandy N. removed_email_address@domain.invalid