30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'app/controllers/witch_doctor/virus_scans_controller.rb', line 30
def update
authenticate! do
respond_to do |format|
format.json do
begin
@virus_scan = VirusScan.where(scan_result: nil).find params[:id]
@virus_scan.update_attributes virus_scan_params if @virus_scan.errors.any?
json_400 = { title: "Bad Request",
detail: @virus_scan.errors.first.join(' '),
status: '400' }
render json: { errors: [json_400] }, status: 400
else
render WitchDoctor.controller_object_hash_generator.call(@virus_scan.reload)
end
rescue ActionController::ParameterMissing => e
json_406 = { title: "Not Acceptable",
detail: e.to_s,
status: '406' }
render json: { errors: [json_406] }, status: 406
rescue ActiveRecord::RecordNotFound => e
json_404 = { title: "Not Found",
detail: 'Record not found or already scanned',
status:'404' }
render json: { errors: [json_404] }, status: 404
end
end
format.html do
err_json = { title: 'Not Acceptable',
detail: 'needs to be JSON request',
status: '406' }
render json: { errors: [err_json] }, status: 406
end
end
end
end
|