Re: session question..

Jay Pangmi
Sat, 11 Oct 2008 11:57:20 -0000

Frederick Cheung wrote:
> On Oct 11, 7:54�am, Jay Pangmi
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
> wrote:
>> cart item so, Cart.find(session[:cart_id]) is only giving me one row.
>> Hence, despite the fact that a customer has added multiple items in the
>> cart, I could only show the latest item added in the cart to the
>> customer. So, thought of using this:
>>
>> @cart_ids = []
>> session[:cart_id] = cart.id
>> @cart_ids << session[:cart_id]
>
> How could that ever work? That instance variable doesn''t survive
> across requests. You would need something like
>
> cart=Cart.create(......)
> session[:cart_ids] ||= []
> session[:cart_ids] << cart.id
>
> You can then later use Cart.find(session[:cart_ids]) to get all those
> cart objects back.
>
> Fred

Thanks Fred I owe you fortune...

Jay

--
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@googlegroups.com