Sha256: 77a7d736a65917b56bece68db8feb4d352e19dd9892598cb5b7dcdd726e0f082

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

require "slim"

module Errdo
  class ErrorsController < Errdo::ApplicationController

    include Errdo::Helpers::ViewsHelper
    helper_method :user_show_string, :user_show_path

    before_action :authorize_user

    def index
      @errors = Errdo::Error.order(last_occurred_at: :desc).page params[:page]
    end

    def show
      @error = Errdo::Error.find(params[:id])
      @occurrence = selected_occurrence(@error)
    end

    def update
      @error = Errdo::Error.find(params[:id])
      if @error.update(error_params)
        flash[:notice] = "Success updating status!"
      else
        flash[:alert] = "Updating failed"
      end
      @occurrence = selected_occurrence(@error)
      render :show
    end

    private

    def authorize_user
      @authorization_adapter ||= nil
      @authorization_adapter.try(:authorize, params["action"], Errdo::Error)
    end

    def error_params
      params.require(:error).permit(:status)
    end

    def selected_occurrence(error)
      if params[:occurrence_id]
        Errdo::ErrorOccurrence.find(params[:occurrence_id])
      else
        error.error_occurrences.last
      end
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
errdo-0.11.3 app/controllers/errdo/errors_controller.rb
errdo-0.11.2 app/controllers/errdo/errors_controller.rb
errdo-0.11.1 app/controllers/errdo/errors_controller.rb
errdo-0.11.0 app/controllers/errdo/errors_controller.rb
errdo-0.10.0 app/controllers/errdo/errors_controller.rb
errdo-0.9.1 app/controllers/errdo/errors_controller.rb
errdo-0.9.0 app/controllers/errdo/errors_controller.rb