I'm writing an app that has a "wizard" type input section. Think MS Windows Installers.
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.
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.
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.
For example...
WizardController < ApplicationController
def stepOne
@resourceA = ResourceA.new
end
def stepTwo
@resourceA = params[:id]
end
...
def stepFive
end
end
And then I would have my view be on the StepOne view:
<form action='/resourceA/new'/>
and on the StepTwo action
<form action='/resourceA/12345/edit'/>
etc.
But then my resourceA and resourceB controllers would have to know how to redirect to the appropriate step in the wizard_controller. Tangled mess!
Am I anywhere near the right track? Or is there a rails built-in mechanism or plugin that does this kind of thing.