Sha256: c92fb2d542c742c03e30a23ac1c1de6e1c40b7616d0d12304804b4f92434bd4f

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

module ShoppingCart
  class ApplicationController < ActionController::Base
    protect_from_forgery with: :exception
    before_action "authenticate_#{ShoppingCart.user_class.downcase}!".to_sym
    alias_method :current_user, "current_#{ShoppingCart.user_class.downcase}".to_sym

    rescue_from CanCan::AccessDenied do |exception|
      redirect_to '/', alert: exception.message
    end

    protected

    def get_order
      @user = send("current_#{ShoppingCart.user_class.downcase}")
      @current_order = Order.current_order(@user)
    end

    def check_order
      redirect_to root_path unless @current_order && @current_order.order_items_count > 0
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shopping_cart-0.1.0 app/controllers/shopping_cart/application_controller.rb