class ApplicationController < ActionController::Base def after_sign_in_path_for(resource) if resource.admin? stored_location_for(resource) || admin_books_path else stored_location_for(resource) || dashboard_index_path end end def authorized_user! unless current_user && current_user.admin? flash[:alert] = 'You are not authorized to access this page.' redirect_to root_path end end end