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. However, I have a problem: since I''m using session variables, when going to the first page having submitted the data to my database, that remains in the forms, as I let it keep them when submitting additional data that requires a submit and then back to the form (i.e.: A country''s state, that triggers an action that allows you to select a city from that state). I tried to use global variables from Ruby, but when another user is connected, if the submit data is not completed, he overwrites tthe data from the first user''s previous pages and when the submission is done, the last form submits the data from both. Resuming, what i''m looking for is a kind of variable that is global, but also individual at the same time for each user so it doesn''t overwrites each other data. is there any kind of variable that let me do those things? Greetings... The Neurochild --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-16 15:36 UTC
Re: Alternative solution to session and global variables
On 16 Dec 2008, at 14:49, 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. However, > I have a problem: since I''m using session variables, when going to the > first page having submitted the data to my database, that remains in > the forms, as I let it keep them when submitting additional data that > requires a submit and then back to the form (i.e.: A country''s state, > that triggers an action that allows you to select a city from that > state). > > I tried to use global variables from Ruby, but when another user is > connected, if the submit data is not completed, he overwrites tthe > data from the first user''s previous pages and when the submission is > done, the last form submits the data from both. > > Resuming, what i''m looking for is a kind of variable that is global, > but also individual at the same time for each user so it doesn''t > overwrites each other data. is there any kind of variable that let me > do those things? >Nope, either the session or the database. Fred> Greetings... > > The Neurochild > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
The Neurochild
2008-Dec-16 15:51 UTC
Re: Alternative solution to session and global variables
Oh! It''s a shame. Sorry to hear that. I was hoping to use some variable that doesn''t use a lot of space in the app. we have as much 50 session variables inside. Too bad --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2008-Dec-16 16:41 UTC
Re: Alternative solution to session and global variables
On Tue, Dec 16, 2008 at 7:51 AM, The Neurochild <neurochild-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > ... we have as much 50 session variables inside.Sounds like a refactoring opportunity :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''m sorry but don''t really understand. Are you saying that the users share the session information? How is that possible? I thought the session information is unique per user. Pepe On Dec 16, 11:41 am, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Tue, Dec 16, 2008 at 7:51 AM, The Neurochild <neuroch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > ... we have as much 50 session variables inside. > > Sounds like a refactoring opportunity :-) > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2008-Dec-18 05:47 UTC
Re: Alternative solution to session and global variables
On Wed, Dec 17, 2008 at 7:54 PM, pepe <Pepe-gUAqH5+0sKL6V6G2DxALlg@public.gmane.org> wrote:> > I''m sorry but don''t really understand. Are you saying that the users > share the session information?Not at all, just thinking that 50 objects individually stored in session might be covered by a different design pattern :-) -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''m sorry Hassan, I didn''t mean the question to be for you, questionning what you said but as a general question for everybody. I am not very experienced in developing web applications yet and my understanding is that the session information is generated for a given user and is not shared. I have a working application designed around that principle, which is actually identical to what the person in the first posting described. If my assumption about session data is not correct I need to know in order to re-engineer my app. ASAP. So please, set me straight if I''m wrong. Thank you. Pepe On Dec 18, 12:47 am, "Hassan Schroeder" <hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Dec 17, 2008 at 7:54 PM, pepe <P...-gUAqH5+0sKL6V6G2DxALlg@public.gmane.org> wrote: > > > I''m sorry but don''t really understand. Are you saying that the users > > share the session information? > > Not at all, just thinking that 50 objects individually stored in session > might be covered by a different design pattern :-) > > -- > Hassan Schroeder ------------------------ hassan.schroe...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeff Pritchard
2008-Dec-19 05:02 UTC
Re: Alternative solution to session and global variables
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 NeurochildNC, 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2008-Dec-19 18:11 UTC
Re: Alternative solution to session and global variables
On Thu, Dec 18, 2008 at 8:05 PM, pepe <Pepe-gUAqH5+0sKL6V6G2DxALlg@public.gmane.org> wrote:> understanding is that the session information is generated for a given > user and is not shared.That''s true, but beside the point. Storing 50 objects into the session is very different than storing, say, one ID that references a Model object with 50 attributes that''s stored in the DB. Or 5 objects with 10 attributes, or whatever makes sense. HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---