Sha256: 705f34682628c06163d3b6f919539d8960be8c088546bf7306dc552efb7c3ec5

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Admin
  class LogsController < ApplicationController
    before_action(:authenticate_user!) if defined?(Devise)
    before_action { EffectiveResources.authorize!(self, :admin, :effective_logging) }

    include Effective::CrudController
    skip_log_page_views

    if (config = EffectiveLogging.layout)
      layout(config.kind_of?(Hash) ? config[:admin] : config)
    end

    def index
      EffectiveResources.authorize!(self, :index, Effective::Log)
      @datatable = EffectiveLogsDatatable.new(self)
      @page_title = 'Logs'
    end

    def show
      @log = Effective::Log.includes(:logs).find(params[:id])
      EffectiveResources.authorize!(self, :show, @log)

      @log.next_log = Effective::Log.order(:id).where(parent_id: @log.parent_id).where('id > ?', @log.id).first
      @log.prev_log = Effective::Log.order(:id).where(parent_id: @log.parent_id).where('id < ?', @log.id).last

      @page_title = "Log ##{@log.to_param}"

      if @log.logs.present?
        @log.datatable = EffectiveLogsDatatable.new(self, log_id: @log.id)
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
effective_logging-3.1.0 app/controllers/admin/logs_controller.rb