Skip to content

Instantly share code, notes, and snippets.

@thomasstr
Created March 31, 2013 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasstr/5281879 to your computer and use it in GitHub Desktop.
Save thomasstr/5281879 to your computer and use it in GitHub Desktop.
current_cart method for application-controller
def current_cart
Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
cart = Cart.create
session[:cart_id] = cart.id
cart
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment