01 Aug 2013, 19:32
Generic-user-small

Matthias Weidemann (1 post)

Hello fellow brethren,

i can’t seem to get sessions to work. As it is more or less one function with no setup required i am kind of stumped what could cause this. Im attaching the code snippet from the book. It always is rescued and never recovers the session.

I tried it with 3 different browsers with everything enabled i could possibly find (cookies, javascript, …) and failed each time.

module CurrentCart extend ActiveSupport::Concern

private

	def set_cart
		@cart = Cart.find(session[:card_id])
	rescue ActiveRecord::RecordNotFound
		@cart = Cart.create
		session[:cart_id] = @cart.id
	end
end

Any further guidance would be much appreciated, because it is driving me seriously insane :)

Kind Regards, Matthias Weidemann

19 Nov 2013, 03:24
Generic-user-small

Robert Young (2 posts)

I am having the same issues. Instead of remaining in the same session, I continue to create a new cart for each item

27 Dec 2013, 17:12
Generic-user-small

Mike Bonar (7 posts)

Same problem here in Firefox and Safari. I get a new cart each time I click Add to Cart.

28 Dec 2013, 01:06
Generic-user-small

Mike Bonar (7 posts)

Found my error:

session[:cart_id] = @cart.id was

session[:cart_id] = @cart_id

  You must be logged in to comment