The Neurochild wrote:
> Hello, guys.
> 
> I'm using session variables (session[:example]) in my app to do all
> the user session tasks. Additionally I'm also using them to save the
> data from a 3-page sata submission, so when when you click "Submit" on
> the last page, you can send the data from the all the pages. 
...
> The Neurochild

NC,
I've done a design like this before, and the first thing that comes to 
my mind is DON'T DO THAT.  Trust me, it is a pain in the backside from 
beginning to end.

If you really must have a multi-page data form, I suggest (in hindsight) 
that you actually make each page of it supply data to a different table, 
and just associate these second and third, etc. tables with the first 
one.

If you have 3 pages worth of info, make three tables, "main", "second", 
and "third".  Then set up model associations between them such that 
"main" has_one second and has_one third.  Second "belongs_to" main, and 
"third" also belongs_to "main".  (of course, you might choose different 
table names)

So, your first page might be a "user name" and basic "who are you" info. 
Maybe you call that table the "main" table.  When they go to the second 
page, you save that first page of data to the "main" table, and keep the 
ID of that in a session variable.  When they leave the second page 
(either forward or backward), you save the second page data to a new 
"second" table row, and associate it with the "main", by putting that id 
in second.main_id.

Similarly with the third page.

This will save you much angst in the long run.  Cleaner code, fewer 
problems.

HTH,
jp
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to