Flow control for rails - suggestions please

I’ve been talking with some Java programmers who are moving over to Rails. This question often comes up and so I thought I would pose it to the list to see if any of you fine folks have dealt with this before:

What methods / plugins / etc are available for controlling the user’s flow through the application? Is there something similar to Spring WebFlows but not as awful to implement? The flow would walk / force a user through a series of pages like a wizard, where the current step would need to be completed before moving on.

I’ve seen the acts_as_wizard plugin and it looks good for chaining controllers together… but I don’t see how it could prevent one from skipping ahead, or from invoking one of the individual controllers in the chain.

It’s not that difficult to just chain controllers together with redirect and render, but I was just curious to see what others were doing.

Thanks in advance!

Brian Hogan wrote:

I've been talking with some Java programmers who are moving over to Rails.
This question often comes up and so I thought I would pose it to the list to
see if any of you fine folks have dealt with this before:

What methods / plugins / etc are available for controlling the user's flow
through the application? Is there something similar to Spring WebFlows but
not as awful to implement? The flow would walk / force a user through a
series of pages like a wizard, where the current step would need to be
completed before moving on.

I've seen the acts_as_wizard plugin and it looks good for chaining
controllers together... but I don't see how it could prevent one from
skipping ahead, or from invoking one of the individual controllers in the
chain.

It's not that difficult to just chain controllers together with redirect and
render, but I was just curious to see what others were doing.

Thanks in advance!

I've worked up a wizard flow for one of my projects, but haven't yet
had a chance to extract it.

It currently leads the user through a multi-step form and basically
won't let them do anything else until they complete the form or cancel
the wizard.

_Kevin

Hi Brian,

If you need complex flow logic in your app you should look at seaside
wriiten in Smalltalk. http://seaside.st/ which supports continutaions
based backtracking etc.
Check out:
http://www.iam.unibe.ch/~scg/Archive/Papers/Duca04eSeaside.pdf
-bakki

@Bakki Kudva

That’s nice and all but off-topic. I need to focus on solutions for Rails at this time. It’s definitely interesting reading though… thanks for sharing.

@Kevin:

Please share whatever you can :slight_smile: I’d love to not have to reinvent the wheel.

Brian Hogan wrote:

@Kevin:

Please share whatever you can :slight_smile: I'd love to not have to reinvent the wheel.

>
>
>
> Brian Hogan wrote:
> > I've been talking with some Java programmers who are moving over to
> Rails.
> > This question often comes up and so I thought I would pose it to the
> list to
> > see if any of you fine folks have dealt with this before:
> >
> > What methods / plugins / etc are available for controlling the user's
> flow
> > through the application? Is there something similar to Spring WebFlows
> but
> > not as awful to implement? The flow would walk / force a user through a
> > series of pages like a wizard, where the current step would need to be
> > completed before moving on.
> >
> > I've seen the acts_as_wizard plugin and it looks good for chaining
> > controllers together... but I don't see how it could prevent one from
> > skipping ahead, or from invoking one of the individual controllers in
> the
> > chain.
> >
> > It's not that difficult to just chain controllers together with redirect
> and
> > render, but I was just curious to see what others were doing.
> >
> > Thanks in advance!
> >
>
> I've worked up a wizard flow for one of my projects, but haven't yet
> had a chance to extract it.
>
> It currently leads the user through a multi-step form and basically
> won't let them do anything else until they complete the form or cancel
> the wizard.
>
> _Kevin
>
>
> >
>

------=_Part_6679_9568412.1157509841281
Content-Type: text/html; charset=ISO-8859-1
X-Google-AttachSize: 1808

@Kevin:<br><br>Please share whatever you can :slight_smile: I'd love to not have to reinvent the wheel.<br><br><div><span class="gmail_quote">On 9/5/06, <b class="gmail_sendername">_Kevin</b> &lt;<a href="mailto:kevin.olbrich@gmail.com">
kevin.olbrich@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br><br>Brian Hogan wrote:<br>&gt; I've been talking with some Java programmers who are moving over to Rails.
<br>&gt; This question often comes up and so I thought I would pose it to the list to<br>&gt; see if any of you fine folks have dealt with this before:<br>&gt;<br>&gt; What methods / plugins / etc are available for controlling the user's flow
<br>&gt; through the application? Is there something similar to Spring WebFlows but<br>&gt; not as awful to implement? The flow would walk / force a user through a<br>&gt; series of pages like a wizard, where the current step would need to be
<br>&gt; completed before moving on.<br>&gt;<br>&gt; I've seen the acts_as_wizard plugin and it looks good for chaining<br>&gt; controllers together... but I don't see how it could prevent one from<br>&gt; skipping ahead, or from invoking one of the individual controllers in the
<br>&gt; chain.<br>&gt;<br>&gt; It's not that difficult to just chain controllers together with redirect and<br>&gt; render, but I was just curious to see what others were doing.<br>&gt;<br>&gt; Thanks in advance!<br>&gt;
<br><br>I've worked up a wizard flow for one of my projects, but haven't yet<br>had a chance to extract it.<br><br>It currently leads the user through a multi-step form and basically<br>won't let them do anything else until they complete the form or cancel
<br>the wizard.<br><br>_Kevin<br><br><br></div><br>

------=_Part_6679_9568412.1157509841281--

Here's the general structure. Note that this is somewhat specific for
my app, so YMMV...

1. Create a Wizard Controller

mine defines methods like
['next','back','cancel','finish','start','index'].
This controller defines the wizard behavior. By doing some case...when
statements, you can define the behavior of your wizard. Cancelling or
finishing should clear the session[:wizard] hash.

2. create a session hash like session[:wizard]
can contain subkeys like [:step, :name]

3. in the Controller you want the wizard to work with...
I create a method called 'wizard?' that intecepts wizard buttons in the
params (i.e., looking for params[:back]) and redirects them to the
wizard_controller

This method also loads any object required by a particular step in the
wizard, and then returns true if wizard mode is active (by looking for
the presence of session[:wizard]

4. modify the methods in each step as needed to customize it's behavior
in wizard mode.

I also redirect my application's base index method through the Wizard
controller index method. It checks to see if a wizard is defined in
the session, if so, it redirects the user to the appropriate page to
continue the wizard.

My particular wizard saves objects as it goes along, but you could
probably save stuff in the session and only commit it to the DB on
completion of the wizard.

_Kevin

Very cool… thanks so much for sharing.