Class: Dscf::Credit::ScoringParametersController

Inherits:
ApplicationController
  • Object
show all
Includes:
Dscf::Core::AuditableController, Dscf::Core::Common, Dscf::Core::ReviewableController
Defined in:
app/controllers/dscf/credit/scoring_parameters_controller.rb

Instance Method Summary collapse

Instance Method Details

#activateObject



38
39
40
41
42
43
44
# File 'app/controllers/dscf/credit/scoring_parameters_controller.rb', line 38

def activate
  if @obj.update(active: true)
    render_success(data: @obj)
  else
    render_error(errors: @obj.errors.full_messages, status: :unprocessable_entity)
  end
end

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/dscf/credit/scoring_parameters_controller.rb', line 18

def create
  super do
    scoring_parameter = @clazz.new(model_params)
    scoring_parameter.created_by = current_user
    scoring_parameter.reviews.build(context: "default", status: "draft")
    scoring_parameter
  end
end

#deactivateObject



46
47
48
49
50
51
52
# File 'app/controllers/dscf/credit/scoring_parameters_controller.rb', line 46

def deactivate
  if @obj.update(active: false)
    render_success(data: @obj)
  else
    render_error(errors: @obj.errors.full_messages, status: :unprocessable_entity)
  end
end

#updateObject



27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/dscf/credit/scoring_parameters_controller.rb', line 27

def update
  unless @obj.editable?
    return render_error(
      errors: [ "Cannot update scoring parameter after submission. Use modification request workflow instead." ],
      status: :unprocessable_entity
    )
  end

  super
end