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
33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 33 def create @device = Device.new(device_params) if @device.save process_success object: @device else process_error object: @device end end |
#destroy ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 51 def destroy if @device.destroy process_success object: @device else process_error object: @device end end |
#device_types ⇒ Object
59 60 61 62 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 59 def device_types @manufacturer_id = params[:manufacturer_id] render partial: 'device_types' end |
#edit ⇒ Object
28 29 30 31 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 28 def edit @device = Device.find(params[:id]) populate_from_host end |
#for_rack ⇒ Object
69 70 71 72 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 69 def for_rack @rack = ForemanDatacenter::Rack.find(params[:rack_id]) render partial: 'for_rack' end |
#index ⇒ Object
5 6 7 8 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 5 def index @devices = Device.includes(:ipmi_interface, :device_role, :device_type, rack: [:site]). paginate(:page => params[:page]) end |
#inventory ⇒ Object
20 21 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 20 def inventory end |
#new ⇒ Object
23 24 25 26 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 23 def new @device = Device.new populate_from_host end |
#racks ⇒ Object
64 65 66 67 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 64 def racks @site_id = params[:site_id] render partial: 'racks' end |
#show ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 10 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
43 44 45 46 47 48 49 |
# File 'app/controllers/foreman_datacenter/devices_controller.rb', line 43 def update if @device.update(device_params) process_success object: @device else process_error object: @device end end |