Re: session question..

Jay Pangmi
Fri, 10 Oct 2008 13:56:38 -0000

Frederick Cheung wrote:
> This doesn''t seem to make any sense. For example the @cart_items
array
> will only ever contain 1 item, you are storing the whole cart object
> in the session (what''s the point of storing it in the database and
the
> session ?)

session[:cart]=Cart.new(cartobj), what is this doing actually I''m not
sure? As you said just to store carts id in the session, how can I do
that? and while emptying the cart how can I get all the carts'' id
stored
in the session and delete the records with that id from the carts table?
With my current way, how can I validate individual details coz currently
its all coming as params[:cart] coz first I have to validate and if
alright save in the database.

> Actually if you check your code you''ll find that beyond the first
time
> you call add_to_cart it won''t actually do anything.

can you please show me how? I''m not yet familiar with rails code.

> Is you cart object actually an item in a cart (rather than the
> container, as the name usually implies) ?

My cart object (params[:cart]) is all the values passed from the browser
by the customer like date, time etc and this values I''m saving to the
database table. Hope this is what you trying to know.

Thanks fred..