通过redirect_to RAILS保持params

时间:2013-10-08 13:22:32

标签: ruby-on-rails ruby

嘿我想重定向并将我的参数保留在最后一页。参数是invite_token,但我无法让它工作。

我尝试了几个版本:

@invitation = Invitation.find_by_invite_token    
redirect_to sign_up_path(params[:invite_token])
or
redirect_to sign_up_path(params[:invite_token => @invitation.invite_token]

2 个答案:

答案 0 :(得分:0)

redirect_to some_path(invite_token: @invitation.invite_token)
# or
redirect_to controller: :some_controller, action: :create, invite_token: @invitation.invite_token

答案 1 :(得分:0)

通常,如果您需要所有参数来保留,只需传递params

redirect_to sign_up_path(params)