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 H. wrote:

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 K.

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 H. wrote:

Rails.

completed before moving on.

_Kevin
[email protected]> wrote:



Brian H. 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–

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.

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

  2. 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]

  1. 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.