我正在嘗試使用特定的控制器操作將用戶重定向到註冊頁面,但它不起作用。控制器沒有重定向到我期待的位置
在我users_controller.rb,我有:
def pre_approved_with_code_action
@code = params[:code]
if params[:commit] = 'Cancel'
redirect_to root_url
return
end
if params[:commit] = 'Create Account'
flash[:notice] = 'Please register as a new user'
redirect_to new_user_registration_path(:discount_code => @code)
return
end
if params[:commit] = 'Login And Retry'
redirect_to new_user_registration_path(:notice => 'Please register as a new user', :discount_code => @code)
return
end
end
日誌文件說:
Started POST "/pre_approved_with_code_action" for 127.0.0.1 at 2013-06-20 10:05:43 -0700
Processing by UsersController#pre_approved_with_code_action as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"sWENK4ZhisSKHQswUZkDcq8ZxsXU+ym9wQqnYwgPIo4=", "code"=>"SPK_2014", "commit"=>"Create Account"}
Redirected to http://localhost:3000/
所以,它重定向到root_url,不new_user_registration_path。有任何想法嗎?
是的,就是這樣。無視我的答案。 – dmanexe