Class: ForemanDatacenter::RacksController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @rack = ForemanDatacenter::Rack.new(rack_params)

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

#destroyObject



45
46
47
48
49
50
51
# File 'app/controllers/foreman_datacenter/racks_controller.rb', line 45

def destroy
  if @rack.destroy
    process_success object: @rack
  else
    process_error object: @rack
  end
end

#editObject



24
25
# File 'app/controllers/foreman_datacenter/racks_controller.rb', line 24

def edit
end

#indexObject



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

def index
  @racks = ForemanDatacenter::Rack.
    includes(:site, :rack_group, :devices).
    order(:name).
    all
end

#newObject



20
21
22
# File 'app/controllers/foreman_datacenter/racks_controller.rb', line 20

def new
  @rack = ForemanDatacenter::Rack.new
end

#rack_groupsObject



12
13
14
15
# File 'app/controllers/foreman_datacenter/racks_controller.rb', line 12

def rack_groups
  @rack_groups = RackGroup.where(site_id: params[:site_id]).all
  render partial: 'rack_groups'
end

#showObject



17
18
# File 'app/controllers/foreman_datacenter/racks_controller.rb', line 17

def show
end

#updateObject



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

def update
  if @rack.update(rack_params)
    process_success object: @rack
  else
    process_error object: @rack
  end
end