Sha256: dbfed3b18fbc8f348829d120ac8776a9c9779ba6dc94e09da5fda44bc35d0a82

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'ostruct'

module Faalis
  module Dashboard
    class ApplicationController < Faalis::ApplicationController

      include Faalis::Dashboard::DSL

      layout 'faalis/dashboard'

      before_action :authenticate_user!
      before_action :setup_sidebar
      before_action :setup_header

      rescue_from Pundit::NotAuthorizedError, with: :user_not_authorized
      rescue_from ActiveRecord::RecordNotFound, with: :redirect_to_404

      protected

        def setup_header
          @dashboard_section_title = t(controller_name.underscore)
          @dashboard_resource_name = t(controller_name.underscore.singularize)
          @dashboard_section_slug  = t(action_name)
        end

      private

        def user_not_authorized
          flash[:alert] = t('faalis.not_authorized')
          redirect_to new_user_session_path
        end

        def redirect_to_404(e)
          respond_to do |f|
            f.html { redirect_to dashboard_not_found_url }
            f.js { render 'faalis/dashboard/not_found' }
          end
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
faalis-2.0.0.rc6 app/controllers/faalis/dashboard/application_controller.rb
faalis-2.0.0.rc5 app/controllers/faalis/dashboard/application_controller.rb
faalis-2.0.0.rc4 app/controllers/faalis/dashboard/application_controller.rb