# Flow control for rails - suggestions please

**URL:** <https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628>\
**Category:** Rails\
**Created:** [September 5, 2006, 8:30pm UTC](https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628 "2006-09-05T20:30:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [September 5, 2006, 8:30pm UTC](https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628/1 "2006-09-05T20:30:18Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [September 5, 2006, 9:06pm UTC](https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628/2 "2006-09-05T21:06:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [September 5, 2006, 9:10pm UTC](https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628/3 "2006-09-05T21:10:21Z")

</div>

Hi Brian,

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

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [September 6, 2006, 4:49am UTC](https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628/4 "2006-09-06T04:49:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [September 6, 2006, 4:39am UTC](https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628/5 "2006-09-06T04:39:03Z")

</div>

@Kevin:

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

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [September 6, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628/6 "2006-09-06T18:06:28Z")

</div>

Brian H. wrote:

> > Rails.
> > 
> > > completed before moving on.
> > 
> > \_Kevin  
> > removed\_email\_address@domain.invalid\> 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

---

<div class="post-metadata">

**Author:** ![kuma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a587f6/32.png) [@kuma](https://www.ruby-forum.com/u/kuma)\
**Post date:** [September 6, 2006, 6:46pm UTC](https://www.ruby-forum.com/t/flow-control-for-rails-suggestions-please/67628/7 "2006-09-06T18:46:33Z")

</div>

Very cool… thanks so much for sharing.
