# A series of views (how to flow)

**URL:** <https://www.ruby-forum.com/t/a-series-of-views-how-to-flow/158907>\
**Category:** Rails\
**Created:** [January 29, 2009, 9:59am UTC](https://www.ruby-forum.com/t/a-series-of-views-how-to-flow/158907 "2009-01-29T09:59:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [January 29, 2009, 9:59am UTC](https://www.ruby-forum.com/t/a-series-of-views-how-to-flow/158907/1 "2009-01-29T09:59:36Z")

</div>

I just want to setup a series of pages so that a user clicks through to  
create a new contact in my test app (a simple address book).

Such that the flow is like this for the user, each action is a new page.

NEW\_CONTACT -\> SELECT\_CATEGORY -\> TYPE\_NAME -\> TYPE\_ADDRESS -\> SAVE

that’s it.

Thing is I can’t quite figure how to do this.

Do I set up lots of actions and views.

e.g

def new  
end

def select\_category

# I intend to find all the categories and display a list on the screen

end

etc…

And then a new view with a button\_to action that redirects to the  
select\_category action?

How do I pass this record between actions.

I just can’t think of the right way to flow this and pass the new  
records details between actions and views?

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [January 29, 2009, 11:08am UTC](https://www.ruby-forum.com/t/a-series-of-views-how-to-flow/158907/2 "2009-01-29T11:08:17Z")

</div>

bingo bob wrote:

> I just want to setup a series of pages so that a user clicks through to  
> create a new contact in my test app (a simple address book).
> 
> Such that the flow is like this for the user, each action is a new page.
> 
> NEW\_CONTACT -\> SELECT\_CATEGORY -\> TYPE\_NAME -\> TYPE\_ADDRESS -\> SAVE
> 
> that’s it.
> 
> Thing is I can’t quite figure how to do this.
> 
> Do I set up lots of actions and views.
> 
> e.g
> 
> def new  
> end
> 
> def select\_category
> 
> # I intend to find all the categories and display a list on the screen
> 
> end
> 
> etc…
> 
> And then a new view with a button\_to action that redirects to the  
> select\_category action?
> 
> How do I pass this record between actions.
> 
> I just can’t think of the right way to flow this and pass the new  
> records details between actions and views?

Hiya Bob,

A couple of different ways to acheive the solution you need:

You can have a action & view for each stage of the process. If you  
submit back to the next action you take the new bit of information and  
save it (either to session or to a temporary record in the database).  
Once you reach the last action you do the final save for the data. You  
could do a similar thing but use AJAX to build up each section which  
would make the user experience a little better.

An alternative would be have one action and view with all the stages  
that you require. You put each section in a seperate div and use  
javascript to show or hide the relevent piece of form you want the user  
to see. The advantage of this is you can send all the required data in  
one submit, the disadvantage is a user could turn off css and see the  
whole form in one hit or they might have javascript turned off.

Cheers  
Luke

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [January 29, 2009, 4:19pm UTC](https://www.ruby-forum.com/t/a-series-of-views-how-to-flow/158907/3 "2009-01-29T16:19:36Z")

</div>

All things being equal which method would you favour?

Waht would be some example code, for either, how do i pass the details  
from one action to another or use the javascript div hiding technique.

I think the div hiding technique sounds best but you wouldn’t have a  
page progression (maybe that’s a bit old school though, not very web  
2.0). I just thought I’d like to set up a series of pages like you  
suggest with the details being built and then saved at the end (in the  
last action).

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [January 29, 2009, 4:25pm UTC](https://www.ruby-forum.com/t/a-series-of-views-how-to-flow/158907/4 "2009-01-29T16:25:11Z")

</div>

I think that you could use a plugin like acts\_as\_wizard for your  
purpouses.

> **[GitHub - adkron/actsaswizard: A Rails plugin to make creating a wizard easy and...](https://github.com/adkron/actsaswizard/tree/master)**
>
> master

[http://blogs.smarteguru.com/2008/09/get-wizard-feel-with-acts-as-wizard-in-ruby-on-rails/](http://blogs.smarteguru.com/2008/09/get-wizard-feel-with-acts-as-wizard-in-ruby-on-rails/)

bingo bob escribiÃ³:
