Class: ForemanDatacenter::DevicesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ForemanDatacenter::DevicesController
- Defined in:
- app/controllers/foreman_datacenter/devices_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #device_types ⇒ Object
- #edit ⇒ Object
- #for_rack ⇒ Object
- #index ⇒ Object
- #inventory ⇒ Object
- #new ⇒ Object
- #racks ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 29 def create @device = Device.new(device_params) if @device.save process_success object: @device else process_error object: @device end end |
#destroy ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 47 def destroy if @device.destroy process_success object: @device else process_error object: @device end end |
#device_types ⇒ Object
55 56 57 58 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 55 def device_types @manufacturer_id = params[:manufacturer_id] render partial: 'device_types' end |
#edit ⇒ Object
26 27 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 26 def edit end |
#for_rack ⇒ Object
65 66 67 68 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 65 def for_rack @rack = ForemanDatacenter::Rack.find(params[:rack_id]) render partial: 'for_rack' end |
#index ⇒ Object
5 6 7 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 5 def index @devices = Device.includes(:device_role, :device_type, rack: [:site]).all end |
#inventory ⇒ Object
19 20 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 19 def inventory end |
#new ⇒ Object
22 23 24 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 22 def new @device = Device.new end |
#racks ⇒ Object
60 61 62 63 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 60 def racks @site_id = params[:site_id] render partial: 'racks' end |
#show ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 9 def show @device = Device.includes( device_bays: [:installed_device], console_server_ports: [:console_port], power_outlets: [:power_port], console_ports: [:console_server_port], power_ports: [:power_outlet] ).find(params[:id]) end |
#update ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 39 def update if @device.update(device_params) process_success object: @device else process_error object: @device end end |