views:

22

answers:

2

Hi folks,

this time it's about Ruby On Rails.

I have a form in the view "progress.html.erb" and an action called "progress". When the form is sent, the action "progress" is called again. This must be like that, because I'm asking the user several questions by an automatic system.

Then, when the questioning is finished and the user is done with one seminar of questions, I want to route out of "progress" to "finishing" (where session data is erased and a "happy wishes"-site is shown).

But this won't work because of that routing error. There must be a way, even just rendering won't work :(

The complete system is the following: I have a box with different panels. In these panels are cards with questions. All card get asked to the user. When all panels evaluate to empty, the user is done.

Please help me!

Yours, Joern.

A: 

I'm not sure what routing error you're getting. Your question/problem isn't very clear. However, it sounds like you want to redirect_to(:finishing) at the end of #progress when the user is "done".

Chris
ActionController::DoubleRenderError (Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return".):
Joern Akkermann
this is what I get when I do as you say
Joern Akkermann
+1  A: 

When you want to redirect, and then stop rendering, you need to not reach the end of control of the function. The way I do this (for redirecting when someone is somewhere they are not supposed to be, usually) is:

redirect_to(:finishing) and return

optionally, you can do this conditionally:

redirect_to(:finishing) and return if @survey.completed?
jamuraa
yeah thanks, this works!
Joern Akkermann