# State Management Rails

**URL:** <https://www.ruby-forum.com/t/state-management-rails/170671>\
**Category:** Rails\
**Created:** [June 20, 2009, 8:35pm UTC](https://www.ruby-forum.com/t/state-management-rails/170671 "2009-06-20T20:35:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 20, 2009, 8:35pm UTC](https://www.ruby-forum.com/t/state-management-rails/170671/1 "2009-06-20T20:35:37Z")

</div>

Hi,

I’m new to rails and I have a question about how to manage state in  
rails application in general.

How would I solve the following szenario:

I have an application in which a user has to fill out a html form.  
This form corresponds to a/the main model, for example an organizer  
who hosts several events.

On the same page the user can select a link, which will lead him to  
another html page on which he can create events and save them.

After the user has saved the event he will automatically be sent back  
to the page from which he came and the event will be added to the  
organizer’s event list.

Now the problem is this:

1. The user fills out the first form with information about an  
organizer and then clicks on the “create events” link.
2. He arrives at the event page and fill out the form with the event  
information and is sent back to where he came from

Now, all the selections and user input the user has made about the  
organizer is lost, because the organizer was not saved yet.

How do you handle conversations in rails between the user and the  
application in which several models have to be initialized first and  
then saved all together?

The user can also return to the previous pages/forms and make changes?

It would be ideal if the models could be tied directly to the forms  
and the models are synchronized with the user forms everytime the user  
moves to a different page.

But I guess, because of rails restfull design architecture this is  
done automatically, but can only be achieved manually by  
synchroinizing the session with the input of the user from the forms?!

How do you implement wizard like navigation in rails? Are there any  
plugins? Do you have something like a conversation in seam/java?

Fritz

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 21, 2009, 1:00am UTC](https://www.ruby-forum.com/t/state-management-rails/170671/2 "2009-06-21T01:00:13Z")

</div>

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> Hi,
> 
> I’m new to rails and I have a question about how to manage state in  
> rails application in general.
> 
> How would I solve the following szenario:
> 
> I have an application in which a user has to fill out a html form.  
> This form corresponds to a/the main model, for example an organizer  
> who hosts several events.
> 
> On the same page the user can select a link, which will lead him to  
> another html page on which he can create events and save them.
> 
> After the user has saved the event he will automatically be sent back  
> to the page from which he came and the event will be added to the  
> organizer’s event list.
> 
> Now the problem is this:
> 
> 1. The user fills out the first form with information about an  
> organizer and then clicks on the “create events” link.
> 2. He arrives at the event page and fill out the form with the event  
> information and is sent back to where he came from
> 
> Now, all the selections and user input the user has made about the  
> organizer is lost, because the organizer was not saved yet.
> 
> How do you handle conversations in rails between the user and the  
> application in which several models have to be initialized first and  
> then saved all together?
> 
> The user can also return to the previous pages/forms and make changes?
> 
> It would be ideal if the models could be tied directly to the forms  
> and the models are synchronized with the user forms everytime the user  
> moves to a different page.
> 
> But I guess, because of rails restfull design architecture this is  
> done automatically, but can only be achieved manually by  
> synchroinizing the session with the input of the user from the forms?!
> 
> How do you implement wizard like navigation in rails? Are there any  
> plugins? Do you have something like a conversation in seam/java?
> 
> Fritz
> ```

May not be the best way but what I have done is to save it to the db with a flag indicating that it is not confirmed.&nbsp; Later when all of the data is gathered I will set the flag (in the db) indicating this is valid data.&nbsp; I also periodicly go through the db destroying old entries where the data is not confirmed.  
  
YMMV  
Norm  
  
--~--~---------~--~----~------------~-------~--~----~  
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.   
 To post to this group, send email to removed\_email\_address@domain.invalid   
 To unsubscribe from this group, send email to removed\_email\_address@domain.invalid   
 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en  
-~----------~----~----~----~------~----~------~--~---
