dashboard controller

This commit is contained in:
Mark Moser
2016-09-21 17:04:08 -05:00
parent 4a70b795e5
commit 7774a1e3f2
13 changed files with 94 additions and 76 deletions

View File

@ -0,0 +1,10 @@
# frozen_string_literal: true
module Admin
class DashboardController < AdminController
def show
authorize :dashboard
@quizzes = policy_scope Quiz.includes(:questions).all
@users = policy_scope User.order(:role, :name)
end
end
end

View File

@ -4,17 +4,10 @@ class AdminController < ApplicationController
layout 'admin'
before_action :authorize_user
after_action :verify_authorized, except: :index
after_action :verify_policy_scoped, only: :index
rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
# TODO: move to DashboardController#index
def dashboard
authorize :admin, :dashboard?
@quizzes = Quiz.includes(:questions).all
@users = User.order(:role, :name)
end
after_action :verify_authorized, except: :index
after_action :verify_policy_scoped, only: :index
def current_user
@current_user ||= User.find_by(id: session[:user]) if session[:user]