Class: ForemanDatacenter::ManufacturersController

Inherits:
ApplicationController show all
Includes:
Foreman::Controller::AutoCompleteSearch, Controller::Parameters::Manufacturer
Defined in:
app/controllers/foreman_datacenter/manufacturers_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



22
23
24
25
26
27
28
29
30
# File 'app/controllers/foreman_datacenter/manufacturers_controller.rb', line 22

def create
  @manufacturer = Manufacturer.new(manufacturer_params)

  if @manufacturer.save
    process_success object: @manufacturer
  else
    process_error object: @manufacturer
  end
end

#destroyObject



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/foreman_datacenter/manufacturers_controller.rb', line 40

def destroy
  unless params['object_only']
    @manufacturer.device_types.each { |dt| dt.devices.each { |d| d.destroy }; dt.destroy }
  else
    @manufacturer.device_types.delete_all(:nullify)
  end

  if @manufacturer.destroy
    process_success success_redirect: manufacturers_path
  else
    process_error
  end
end

#editObject



19
20
# File 'app/controllers/foreman_datacenter/manufacturers_controller.rb', line 19

def edit
end

#indexObject



8
9
10
# File 'app/controllers/foreman_datacenter/manufacturers_controller.rb', line 8

def index
  @manufacturers = resource_base_search_and_page.includes(:device_types)
end

#newObject



15
16
17
# File 'app/controllers/foreman_datacenter/manufacturers_controller.rb', line 15

def new
  @manufacturer = Manufacturer.new
end

#showObject



12
13
# File 'app/controllers/foreman_datacenter/manufacturers_controller.rb', line 12

def show
end

#updateObject



32
33
34
35
36
37
38
# File 'app/controllers/foreman_datacenter/manufacturers_controller.rb', line 32

def update
  if @manufacturer.update(manufacturer_params)
    process_success object: @manufacturer
  else
    process_error object: @manufacturer
  end
end