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



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

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

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

#destroyObject



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

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

#editObject



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

def edit
end

#indexObject



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

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

#newObject



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

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

#rack_groupsObject



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

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

#showObject



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

def show
end

#updateObject



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

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