Sha256: 8dc1beb8c984083e5aeb3c518434c662ae92481ae8139ff8c1b3fc733f864f3d
Contents?: true
Size: 991 Bytes
Versions: 18
Compression:
Stored size: 991 Bytes
Contents
module Shoppe class ApplicationController < ActionController::Base before_filter :login_required rescue_from ActiveRecord::DeleteRestrictionError do |e| redirect_to request.referer || root_path, :alert => e.message end rescue_from Shoppe::Error do |e| @exception = e render :layout => 'shoppe/sub', :template => 'shoppe/shared/error' end private def login_required unless logged_in? redirect_to login_path end end def logged_in? current_user.is_a?(User) end def current_user @current_user ||= login_from_session || login_with_demo_mdoe || :false end def login_from_session if session[:shoppe_user_id] @user = User.find_by_id(session[:shoppe_user_id]) end end def login_with_demo_mdoe if Shoppe.settings.demo_mode? @user = User.first end end helper_method :current_user, :logged_in? end end
Version data entries
18 entries across 18 versions & 3 rubygems