Class: NdrError::ErrorsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ndr_error/errors_controller.rb

Overview

Controller for viewing and managing errors

Instance Method Summary collapse

Instance Method Details

#destroyObject



42
43
44
45
46
# File 'app/controllers/ndr_error/errors_controller.rb', line 42

def destroy
  flash[:error] = 'Fingerprint purged!' if @fingerprint.purge!

  redirect_to error_fingerprints_url
end

#editObject



28
# File 'app/controllers/ndr_error/errors_controller.rb', line 28

def edit; end

#indexObject



7
8
9
10
11
12
13
14
# File 'app/controllers/ndr_error/errors_controller.rb', line 7

def index
  if NdrError::Log.perform_cleanup!
    flash[:notice] = 'Scheduled deletion of historical logs completed.'
  end

  @keywords     = extract_keywords(params[:q])
  @fingerprints = NdrError.paginate(@keywords, params[:page])
end

#showObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/ndr_error/errors_controller.rb', line 16

def show
  logs   = @fingerprint.error_logs.not_deleted
  @error = (id = params[:log_id]) ? logs.find_by(error_logid: id) : logs.first

  if @error.nil?
    flash[:error] = 'No matching Logs exist for that Fingerprint!'
    redirect_to error_fingerprints_url(q: @fingerprint.to_param)
  elsif id.blank?
    redirect_to log_id: @error.id
  end
end

#updateObject



30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/ndr_error/errors_controller.rb', line 30

def update
  @fingerprint.ticket_url = params[:error_fingerprint][:ticket_url]

  if @fingerprint.save
    flash[:notice] = 'The Error Fingerprint was successfully updated!'
    redirect_to error_fingerprint_url(@fingerprint)
  else
    flash.now[:error] = errors_for(@fingerprint)
    render 'edit'
  end
end