Class: ForemanDatacenter::DeviceModulesController

Inherits:
ApplicationController show all
Includes:
Controller::Parameters::DeviceModule
Defined in:
app/controllers/foreman_datacenter/device_modules_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_modules_controller.rb', line 16

def create
  @device_module = ForemanDatacenter::DeviceModule.new(device_module_params.merge(device_id: params[:device_id]))

  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



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

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



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

def edit
end

#newObject



7
8
9
10
11
# File 'app/controllers/foreman_datacenter/device_modules_controller.rb', line 7

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

#updateObject



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

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