class ApplicationController < ActionController::Base protect_from_forgery with: :exception before_filter :authenticate_user!, unless: :pages_controller? include Pundit protect_from_forgery after_action :verify_authorized, except: :index, unless: :devise_or_pages_controller? after_action :verify_policy_scoped, only: :index, unless: :devise_or_pages_controller? rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized private def user_not_authorized flash[:error] = I18n.t('controllers.application.user_not_authorized', default: "You can't access this page.") redirect_to(tracks_path) end def devise_or_pages_controller? devise_controller? || pages_controller? end def pages_controller? controller_name == "pages" # Brought by the `high_voltage` gem end end