Paul S.
Paul S.

Reputation: 4492

Passing arguments when using redirect_to

In my Rails controller, in one method I do a redirect_to to another path (i.e. another method). I want to also pass arguments from the first method, so that the second method can use them. Is that possible?

Upvotes: 2

Views: 151

Answers (1)

Dipak Panchal
Dipak Panchal

Reputation: 6036

you can do like this

for example:

redirect_to new_user_url(@user)

You can receive @user in your new user page.

or

redirect_to action_name_resource_path(resource_object, {:param_1 => 'value_1', :param_2 => 'value_2'})

or

redirect_to new_users_path(request.parameters)

Upvotes: 1

Related Questions