# SESSIONS, REST and multi-step / multi-page forms

**URL:** <https://www.ruby-forum.com/t/sessions-rest-and-multi-step-multi-page-forms/140466>\
**Category:** Rails\
**Created:** [June 14, 2008, 2:07pm UTC](https://www.ruby-forum.com/t/sessions-rest-and-multi-step-multi-page-forms/140466 "2008-06-14T14:07:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_J\_Mucklo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/3da27b/32.png) [@Matthew\_J\_Mucklo](https://www.ruby-forum.com/u/Matthew_J_Mucklo)\
**Post date:** [June 14, 2008, 2:07pm UTC](https://www.ruby-forum.com/t/sessions-rest-and-multi-step-multi-page-forms/140466/1 "2008-06-14T14:07:09Z")

</div>

Greetings,

I have a question regarding using sessions with REST.

I’m wondering if passing form data between controllers using sessions  
is not recommended for Rails / REST?

I need to prepopulate a form, based on information from another form  
(which doesn’t have a model behind it).

You could think of this as a multi-step form where the first step  
determines the inputs displayed in the second step. Javascript-tabs  
are not really good here unless I use AJAX to populate the second step  
of the form…Even then a ‘tab’ interface is not desired (the user  
should have no way of switching back and forth, or any idea that it’s  
a multi-step form from the interface side, the user should just fill  
one form, which leads to a second, created based on data from the  
first.

My plan was to use a separate controller for the first step which  
would pass parameters to the main controller to render the second step  
in its new method, through via the rails session variable.

The first controller would render the first step via its ‘new’  
action. Upon posting, it would take the :params posted into the  
‘create’ action and use it to place variables into the Rails session  
variable. Then the same ‘create’ action would redirect the browser to  
the second controller’s ‘new’ action which would then pickup the  
variables needed to construct the second, main, part of the form from  
the Rails session variable.

Unfortunately it makes the ‘new’ method of the main controller  
unfunctional without the Rails session being initialized by the first  
controller’s ‘create’ action (as it needs those extra parameters in  
order to layout the second, main part of the form)

Is this a un-RESTful way to do things (passing extra data around via  
sessions)? Should I instead pass a querystring to the ‘new’ method of  
the main controller? Should I lump everything into the main  
controller some how?

Your thoughts?

–Matt
