Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a wizard that works with multiple Resources
    text
    copied!<p>I'm writing an app that has a "wizard" type input section. Think MS Windows Installers.</p> <p>I'm having a hard time figuring out how the most RESTful way to do this with rails. I can make it happen in a non-restful way (already did for version 1 of the app), but I'm trying to be a little more idiomatic this time around.</p> <p>Here's the situation. I have a 5 step wizard that has to gather information. Steps 1, 2, and 4 deal with resource A. Step 3 deals with multiples of resource B and must associate them to resource A. Step 5 is just a confirmation.</p> <p>So I have my resourceA_controller and my resourceB_controller...but they only save/update that one resource. I'm guessing that I should set up a wizard_controller for each of the steps in the process, but I'm not sure how the routing should work.</p> <p>For example...</p> <pre><code>WizardController &lt; ApplicationController def stepOne @resourceA = ResourceA.new end def stepTwo @resourceA = params[:id] end ... def stepFive end end </code></pre> <p>And then I would have my view be on the StepOne view:</p> <pre><code>&lt;form action='/resourceA/new'/&gt; </code></pre> <p>and on the StepTwo action</p> <pre><code>&lt;form action='/resourceA/12345/edit'/&gt; </code></pre> <p>etc.</p> <p>But then my resourceA and resourceB controllers would have to know how to redirect to the appropriate step in the wizard_controller. Tangled mess!</p> <p>Am I anywhere near the right track? Or is there a rails built-in mechanism or plugin that does this kind of thing.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload