HighDots Forums  

Where to save temp data?

Ruby On Rails Talk Ruby On Rails programming language mailing list


Discuss Where to save temp data? in the Ruby On Rails Talk forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Heinz Strunk
 
Posts: n/a

Default Where to save temp data? - 11-06-2009 , 12:26 PM






Hello,

I need some advice. I have a form that has data from 4 different tables
and about 10 values to save and keep until the form is finally sent.

Where would you save the 10 values (all strings or integers, of course)?
Session? Cookie? Pass them around as parameter?

I'm a bit confused and would highly appreciate any suggestions.

Thanks!
--
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 rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #2  
Old   
Marnen Laibow-Koser
 
Posts: n/a

Default Re: Where to save temp data? - 11-06-2009 , 03:59 PM






Heinz Strunk wrote:
Quote:
Hello,

I need some advice. I have a form that has data from 4 different tables
and about 10 values to save and keep until the form is finally sent.

Where would you save the 10 values (all strings or integers, of course)?
Session? Cookie? Pass them around as parameter?
If it's only one request cycle, there's no real need to save temp data.
What are you trying to do?


Quote:
I'm a bit confused and would highly appreciate any suggestions.

Thanks!
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen (AT) marnen (DOT) org
--
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 rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #3  
Old   
Heinz Strunk
 
Posts: n/a

Default Re: Where to save temp data? - 11-06-2009 , 06:23 PM



Marnen Laibow-Koser wrote:
Quote:
If it's only one request cycle, there's no real need to save temp data.
What are you trying to do?

That's exactly my problem, otherwise I would be using variables. It's
many request cycles going back and forth that's why I need a proper way
to save some data. I'm doing it by passing parameters but it's confusing
and I don't like parameter when handling so many variables.
--
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 rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #4  
Old   
Hassan Schroeder
 
Posts: n/a

Default Re: Where to save temp data? - 11-06-2009 , 06:51 PM



On Fri, Nov 6, 2009 at 3:23 PM, Heinz Strunk
<rails-mailing-list (AT) andreas-s (DOT) net> wrote:

Quote:
That's exactly my problem, otherwise I would be using variables. It's
many request cycles going back and forth that's why I need a proper way
to save some data. I'm doing it by passing parameters but it's confusing
and I don't like parameter when handling so many variables.
Is there any chance your form data needs to persist across sessions,
(as in user leaves, comes back, resumes filling in unfinished form)?

If not, you could save your variables in a hash in session. Otherwise
I would create a Form model and save it to the DB.

FWIW,
--
Hassan Schroeder ------------------------ hassan.schroeder (AT) gmail (DOT) com
twitter: @hassan

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

Reply With Quote
  #5  
Old   
Heinz Strunk
 
Posts: n/a

Default Re: Where to save temp data? - 11-07-2009 , 03:49 AM



Hassan Schroeder wrote:
Quote:
Is there any chance your form data needs to persist across sessions,
(as in user leaves, comes back, resumes filling in unfinished form)?

If not, you could save your variables in a hash in session. Otherwise
I would create a Form model and save it to the DB.

No, user doesn't leave. It just could end up in many request cycles.
Didn't have the Session a very small amount of data it can save?
--
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 rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #6  
Old   
Hassan Schroeder
 
Posts: n/a

Default Re: Where to save temp data? - 11-07-2009 , 01:04 PM



On Sat, Nov 7, 2009 at 12:49 AM, Heinz Strunk
<rails-mailing-list (AT) andreas-s (DOT) net> wrote:

Quote:
No, user doesn't leave. It just could end up in many request cycles.
Didn't have the Session a very small amount of data it can save?
That depends on how you're handling sessions, but the more I think
about it, I'd just go with the Form object and saving changes to the
DB across requests.

FWIW,
--
Hassan Schroeder ------------------------ hassan.schroeder (AT) gmail (DOT) com
twitter: @hassan

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

Reply With Quote
  #7  
Old   
Colin Law
 
Posts: n/a

Default Re: Where to save temp data? - 11-07-2009 , 04:27 PM



2009/11/6 Heinz Strunk <rails-mailing-list (AT) andreas-s (DOT) net>:
Quote:
Marnen Laibow-Koser wrote:

If it's only one request cycle, there's no real need to save temp data.
What are you trying to do?

That's exactly my problem, otherwise I would be using variables. It's
many request cycles going back and forth that's why I need a proper way
to save some data. I'm doing it by passing parameters but it's confusing
and I don't like parameter when handling so many variables.
If you are only talking about a few hundred bytes or less then you can
certainly save it in the session. The alternative is to use fields in
something like the User table, assuming there is one.

Colin

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

Reply With Quote
  #8  
Old   
Heinz Strunk
 
Posts: n/a

Default Re: Where to save temp data? - 11-09-2009 , 10:15 AM



Well, most of it is actullay not any data that's going to be saved in
the database. I need to know various numbers like "current number of
users", "maximum number of users", "ids of the users" and stuff like
that.

So I guess I should go for the session?
--
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 rubyonrails-talk (AT) googlegroups (DOT) com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe (AT) googlegroups (DOT) com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply With Quote
  #9  
Old   
Colin Law
 
Posts: n/a

Default Re: Where to save temp data? - 11-09-2009 , 10:35 AM



2009/11/9 Heinz Strunk <rails-mailing-list (AT) andreas-s (DOT) net>:
Quote:
Well, most of it is actullay not any data that's going to be saved in
the database. I need to know various numbers like "current number of
users", "maximum number of users", "ids of the users" and stuff like
that.

So I guess I should go for the session?
What do you mean by "current number of users"? Do you mean how many
users are logged on? I got the impression in your original post that
we were talking about data entered by the user. How do you know how
many users are currently logged on? Remember that a session is on a
user by user basis. If you want to remember data across users I think
you will have to put it in the db.

Colin

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

Reply With Quote
  #10  
Old   
Peter De Berdt
 
Posts: n/a

Default Re: Where to save temp data? - 11-09-2009 , 10:53 AM



On 09 Nov 2009, at 16:35, Colin Law wrote:

Quote:
Well, most of it is actullay not any data that's going to be saved in
the database. I need to know various numbers like "current number of
users", "maximum number of users", "ids of the users" and stuff like
that.

So I guess I should go for the session?

What do you mean by "current number of users"? Do you mean how many
users are logged on? I got the impression in your original post that
we were talking about data entered by the user. How do you know how
many users are currently logged on? Remember that a session is on a
user by user basis. If you want to remember data across users I think
you will have to put it in the db.
Indeed, with the ActiveRecord store, you could count the number of
sessions that were active in the last x minutes, but even that's just
an approximate value. With the CookieStore, you don't have a way to
determine the number of active users that easily (which certainly
doesn't mean you have to use the ActiveRecordStore again).

The only reliable way is maintaining a persistent connection to the
server (using Juggernaut or Comet for example). When that connection
is terminated, the user has logged off (it will even provide instant
feedback when the window is closed, but the session is still
persisting in the user's browser).


Best regards

Peter De Berdt


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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.