Class: ForemanDatacenter::DeviceModulesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/foreman_datacenter/device_modules_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/foreman_datacenter/device_modules_controller.rb', line 14

def create
  @device_module = DeviceModule.new(device_module_params)

  if @device_module.save
    redirect_to inventory_device_url(id: @device_module.device_id),
                notice: 'Device module was successfully created.'
  else
    process_error object: @device_module
  end
end

#destroyObject



34
35
36
37
38
39
40
41
# File 'app/controllers/foreman_datacenter/device_modules_controller.rb', line 34

def destroy
  if @device_module.destroy
    redirect_to inventory_device_url(id: @device_module.device_id),
                notice: 'Device module was successfully destroyed.'
  else
    process_error object: @device_module
  end
end

#editObject



11
12
# File 'app/controllers/foreman_datacenter/device_modules_controller.rb', line 11

def edit
end

#newObject



5
6
7
8
9
# File 'app/controllers/foreman_datacenter/device_modules_controller.rb', line 5

def new
  @device_module = DeviceModule.new(
    device: Device.find(params[:device_id])
  )
end

#updateObject



25
26
27
28
29
30
31
32
# File 'app/controllers/foreman_datacenter/device_modules_controller.rb', line 25

def update
  if @device_module.update(device_module_params)
    redirect_to inventory_device_url(id: @device_module.device_id),
                notice: 'Device module was successfully updated.'
  else
    process_error object: @device_module
  end
end