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
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
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
Alan F. 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] = …
Thanks
Qasim Ali wrote:
Alan F. 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] = …Thanks
See 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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs