Monday 15 April 2013

ruby on rails - Controller not redirecting where I'm expecting it to -


I am a user tries to access a specific controller action to redirect to the registration page, but it works not doing.

In my users_controller.rb, I have:

  def pre_approved_with_code_action @code = params [: code] If Pram [: commode] = Cancel '' redirect_to root_url back end if parameter [committed] = 'Create account' flash [: notice] = 'Please end a new user as the register' redirect_to new_user_registration_path (: discount_code = & gt; @code) return if params [ : Commit] = 'Login and try again' redirect_to new_user_registration_path (: notice = & gt; please register as a new user ',: discount_code = & gt; ; @code) Return and end   

The log file says:

  2013-06-20 to 127.0.0.1 for POST "/ pre_approved_with_code_action" 10:05:43 -0700 processing user controller # pre_approved_with_code_action as HTML parameter: {"utf8" => "A" ??? "Pramanikta_tokn" = & Gt; "sWENK4ZhisSKHQswUZkDcq8ZxsXU + ym9wQqnYwgPIo4 =", "code" = & Http: // localhost: is redirected to 3000 /   

, Then it is being redirected to root_ url, not new_user_registration_path. any idea?

Simple mistake, you need to

instead of Params [: commit] = 'Cancel' should be if the question [: commod] == 'cancel'

No comments:

Post a Comment