Re: session question..

Frederick Cheung
Fri, 10 Oct 2008 08:13:41 -0000

On Oct 10, 9:07 am, Jay Pangmi
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
> database. So I''ve also made Cart class but I have
''carts'' table as well.
> So, I''ve used <%form_for :cart ....%> to get all the details
from the
> form in one object and done @cart=find_cart(params[:cart]) and find_cart
> method as: (I''m not sure if its right way. I even don''t
know what
> exactly is happening between sessions table which was created via
> db:session:create and my ''carts'' table.)
> ---------------------------------------------------------------------------
-----
> def find_cart(cartobj)
>  session[:cart] ||= Cart.new(cartobj)
> end

If carts are saved in the database I would just save its id in the
session. If this is all you''re using here you''re not actually
saving
anything in the carts table at all.

> ---------------------------------------------------------------------------
-----
>
> so far so good, details got saved but when it came to emptying the cart
> list, I''m confused what to do. Author has done it as:

Your would just retrieve the cart object and destroy it.

Fred
--~--~---------~--~----~------------~-------~--~----~
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