I try to be as RESTful as possible in building applications but one thing that I’m never sure about is how to create a wizard-type work flow, be RESTful and concise.
Take, for example, a multi-page sign-up process.
Option 1: I can create a controller for each step and call new or edit when user gets to that step (or back to it). I end with step1_controller, step2_controller, etc…
Option 2: I can create a one controller and track where they are in the sign-up process with a param, session variable, state-machine – whatever. So I’d have signup_controller/step?id=1
The first option is strictly REST, but not very concise and ends with some number of extra controllers. The second options is more concise, but breaks REST, which I’m willing to do, but I don’t take it lightly.
Is there a better option?
I’m working in ruby on rails, but this question applies to other MVC implementations, like ASP.NET MVC
I’m actually less concerned about maintaining REST in a one-shot wizard. REST is most important, I think, with repeatable actions — you want the url to be basically bookmarkable so that you get back the same view of the data regardless of when you go there. In a multi-step wizard you have dependencies that are going to break this perspective of REST anyway. My feeling is to have a single controller with potentially separate actions or using query parameters to indicate what step you are on. This is how I’ve structured my activation wizards (which require multiple steps) anyway.