Skip to content

Instantly share code, notes, and snippets.

@aahmad
Created January 31, 2011 17:44
Show Gist options
  • Save aahmad/804450 to your computer and use it in GitHub Desktop.
Save aahmad/804450 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protect_from_forgery
protected
def create_cart
puts session.current_session_id
if session[:cart_id]
@current_cart = Cart.select("carts.*, items.*, cart_items.*").includes(:items).find( session[:cart_id] )
end
if session[:cart_id].nil?
@current_cart ||= Cart.create(:session_id => session[:session_id] )
session[:cart_id] = @current_cart.id
end
@current_cart
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment