Class: HrLite::HrRequestsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/hr_lite/hr_requests_controller.rb

Overview

The employee's side of the help desk.

Instance Method Summary collapse

Instance Method Details

#cancelObject



27
28
29
30
31
32
33
# File 'app/controllers/hr_lite/hr_requests_controller.rb', line 27

def cancel
  request = own.find(params[:id])
  request.cancel!(actor: hr_current_user)
  redirect_to hr_requests_path, notice: "Request withdrawn."
rescue ActiveRecord::RecordInvalid
  redirect_to hr_requests_path, alert: "That request has already been answered."
end

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/hr_lite/hr_requests_controller.rb', line 18

def create
  @request = HrRequest.new(request_params.merge(user_id: hr_current_user.id))
  if @request.save
    redirect_to hr_requests_path, notice: "Sent to HR."
  else
    render :new, status: :unprocessable_entity
  end
end

#indexObject



6
7
8
# File 'app/controllers/hr_lite/hr_requests_controller.rb', line 6

def index
  @requests = paginate(own.recent_first)
end

#newObject



14
15
16
# File 'app/controllers/hr_lite/hr_requests_controller.rb', line 14

def new
  @request = HrRequest.new
end

#showObject



10
11
12
# File 'app/controllers/hr_lite/hr_requests_controller.rb', line 10

def show
  @request = own.find(params[:id])
end