Class: Dscf::Credit::CreditLineSpecsController

Inherits:
ApplicationController show all
Includes:
Dscf::Core::Common
Defined in:
app/controllers/dscf/credit/credit_line_specs_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/dscf/credit/credit_line_specs_controller.rb', line 5

def create
  super do
    obj = @clazz.new(model_params)
    obj.created_by = current_user

    if obj.active?
      @clazz.where(credit_line_id: obj.credit_line_id, active: true).update_all(active: false)
    end

    obj
  end
end

#updateObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/dscf/credit/credit_line_specs_controller.rb', line 18

def update
  super do
    obj = set_object

    if model_params[:active] == true || model_params[:active] == "true"
      @clazz.where(credit_line_id: obj.credit_line_id, active: true)
           .where.not(id: obj.id)
           .update_all(active: false)
    end

    obj
  end
end