Hi everyone, I wanted to know how do i save some data in session and later retrieve that. I am new to rails and just couldn''t find any help regarding this. Thank you -- 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 -~----------~----~----~----~------~----~------~--~---
Qasim Ali wrote:> Hi everyone, > > I wanted to know how do i save some data in session and later retrieve > that. > I am new to rails and just couldn''t find any help regarding this. > > Thank youI''d suggest you make a new table to store the session ''object'' (like, say, baskets if its a shopping basket). Then you just do session[:my_basket_id] = @basket.id You are *strongly* advised against just doing session[:basket] = @basket, and storing just the id in the session instead. Does this make sense ? Alan -- 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 -~----------~----~----~----~------~----~------~--~---
Alan Francis wrote:> Qasim Ali wrote: >> Hi everyone, >> >> I wanted to know how do i save some data in session and later retrieve >> that. >> I am new to rails and just couldn''t find any help regarding this. >> >> Thank you > > > I''d suggest you make a new table to store the session ''object'' (like, > say, baskets if its a shopping basket). > > Then you just do > > session[:my_basket_id] = @basket.id > > You are *strongly* advised against just doing session[:basket] = > @basket, and storing just the id in the session instead. > > Does this make sense ? > > AlanThank you Alan for your quick response. But why should we go for the database solution instead of simply utilizing the session variable, is there some specific reason for not using the session[:basket] = ... 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-/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 -~----------~----~----~----~------~----~------~--~---
Qasim Ali wrote:> Alan Francis wrote: >> Qasim Ali wrote: >>> Hi everyone, >>> >>> I wanted to know how do i save some data in session and later retrieve >>> that. >>> I am new to rails and just couldn''t find any help regarding this. >>> >>> Thank you >> >> >> I''d suggest you make a new table to store the session ''object'' (like, >> say, baskets if its a shopping basket). >> >> Then you just do >> >> session[:my_basket_id] = @basket.id >> >> You are *strongly* advised against just doing session[:basket] = >> @basket, and storing just the id in the session instead. >> >> Does this make sense ? >> >> Alan > > Thank you Alan for your quick response. But why should we go for the > database solution instead of simply utilizing the session variable, is > there some specific reason for not using the session[:basket] = ... > > ThanksSee here: http://wiki.rubyonrails.org/rails/pages/sessions Mostly to do with objects being stale, some security issues, and the sheer size of the sessions. A. -- 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 -~----------~----~----~----~------~----~------~--~---