Class: ForemanDatacenter::DeviceBaysController

Inherits:
ApplicationController show all
Includes:
Controller::Parameters::DeviceBay
Defined in:
app/controllers/foreman_datacenter/device_bays_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#action_permission, #controller_permission, #find_resource, #not_found, #resource_class, #resource_class_for, #resource_finder, #resource_name, #resource_scope, #scope_for

Instance Method Details

#createObject



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

def create
  @device_bay = ForemanDatacenter::DeviceBay.new(device_bay_params.merge(device_id: params[:device_id]))

  if @device_bay.save
    redirect_to device_url(@device_bay.device),
                notice: 'New device bay was successfully created'
  else
    process_error object: @device_bay
  end
end

#depopulateObject



58
59
60
61
62
63
64
65
# File 'app/controllers/foreman_datacenter/device_bays_controller.rb', line 58

def depopulate
  if @device_bay.update(installed_device_id: nil)
    redirect_to device_url(@device_bay.device),
                notice: 'Device bay was successfully depopulated'
  else
    process_error object: @device_bay
  end
end

#destroyObject



36
37
38
39
40
41
42
43
# File 'app/controllers/foreman_datacenter/device_bays_controller.rb', line 36

def destroy
  if @device_bay.destroy
    redirect_to device_url(@device_bay.device),
                notice: 'Device bay was successfully destroyed'
  else
    process_error object: @device_bay
  end
end

#editObject



13
14
# File 'app/controllers/foreman_datacenter/device_bays_controller.rb', line 13

def edit
end

#newObject



9
10
11
# File 'app/controllers/foreman_datacenter/device_bays_controller.rb', line 9

def new
  @device_bay = ForemanDatacenter::DeviceBay.new(device: ForemanDatacenter::Device.find(params[:device_id]))
end

#populateObject



48
49
50
51
52
53
54
55
56
# File 'app/controllers/foreman_datacenter/device_bays_controller.rb', line 48

def populate
  device_id = params[:device_bay][:installed_device_id]
  if @device_bay.update(installed_device_id: device_id)
    redirect_to device_url(@device_bay.device),
                notice: 'Device bay was successfully populated'
  else
    process_error object: @device_bay
  end
end

#populate_newObject



45
46
# File 'app/controllers/foreman_datacenter/device_bays_controller.rb', line 45

def populate_new
end

#updateObject



27
28
29
30
31
32
33
34
# File 'app/controllers/foreman_datacenter/device_bays_controller.rb', line 27

def update
  if @device_bay.update(device_bay_params)
    redirect_to device_url(@device_bay.device),
                notice: 'Device bay was successfully updated'
  else
    process_error object: @device_bay
  end
end