Add function User Management, cart, orders with specific user
Showing
| ... | ... | @@ -5,16 +5,20 @@ class ApplicationController < ActionController::Base |
| rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found | ||
| def current_cart | ||
Please
register
or
sign in
to reply
|
||
| Cart.find(session[:cart_id]) | ||
| rescue ActiveRecord::RecordNotFound | ||
| cart = Cart.create | ||
| session[:cart_id] = cart.id | ||
| cart | ||
| end | ||
| include ApplicationHelper | ||
| private | ||
| def after_sign_in_path_for(resource_or_scope) | ||
| if current_user | ||
| current_user.add_line_items_from_cart(current_cart) | ||
| current_user.save | ||
| current_cart.destroy unless current_user.cart == current_cart | ||
| end | ||
| session[:cart_id] = current_user.cart.id | ||
| super | ||
| end | ||
| def record_not_found | ||
| flash[:danger] = 'Record Not found.' | ||
| redirect_to root_path | ||
| ... | ... | |