# frozen_string_literal: true class AdminController < ApplicationController layout 'admin' before_action :authorize_user def dashboard @quizzes = Quiz.includes(:questions).all @users = User.order(:role, :name) end def current_user @current_user ||= User.find_by(id: session[:user]) if session[:user] end helper_method :current_user private def authorize_user redirect_to admin_login_path unless current_user end end