Class: HrLite::Admin::OfficeLocationsController

Inherits:
LeadershipController show all
Defined in:
app/controllers/hr_lite/admin/office_locations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
# File 'app/controllers/hr_lite/admin/office_locations_controller.rb', line 12

def create
  @office_location = OfficeLocation.new(office_location_params)
  if @office_location.save
    redirect_to admin_office_locations_path, notice: "Office added."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



34
35
36
37
# File 'app/controllers/hr_lite/admin/office_locations_controller.rb', line 34

def destroy
  OfficeLocation.find(params[:id]).destroy!
  redirect_to admin_office_locations_path, notice: "Office removed.", status: :see_other
end

#editObject



21
22
23
# File 'app/controllers/hr_lite/admin/office_locations_controller.rb', line 21

def edit
  @office_location = OfficeLocation.find(params[:id])
end

#indexObject



4
5
6
# File 'app/controllers/hr_lite/admin/office_locations_controller.rb', line 4

def index
  @office_locations = OfficeLocation.order(:name)
end

#newObject



8
9
10
# File 'app/controllers/hr_lite/admin/office_locations_controller.rb', line 8

def new
  @office_location = OfficeLocation.new
end

#updateObject



25
26
27
28
29
30
31
32
# File 'app/controllers/hr_lite/admin/office_locations_controller.rb', line 25

def update
  @office_location = OfficeLocation.find(params[:id])
  if @office_location.update(office_location_params)
    redirect_to admin_office_locations_path, notice: "Office updated."
  else
    render :edit, status: :unprocessable_entity
  end
end