Class: HrLite::Admin::AppraisalsController
- Inherits:
-
LeadershipController
- Object
- HrLite::ApplicationController
- BaseController
- LeadershipController
- HrLite::Admin::AppraisalsController
- Defined in:
- app/controllers/hr_lite/admin/appraisals_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/hr_lite/admin/appraisals_controller.rb', line 13 def create @appraisal = Appraisal.new(appraisal_params.merge( user_id: @profile.user_id, reviewer_id: hr_current_user.id )) if @appraisal.save redirect_to admin_employee_path(@profile), notice: "Appraisal drafted — share when ready." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/hr_lite/admin/appraisals_controller.rb', line 46 def destroy appraisal = scoped.find(params[:id]) if appraisal.destroy redirect_to admin_employee_path(@profile), notice: "Draft appraisal removed.", status: :see_other else redirect_to admin_employee_path(@profile), status: :see_other, alert: appraisal.errors..to_sentence end end |
#edit ⇒ Object
24 25 26 |
# File 'app/controllers/hr_lite/admin/appraisals_controller.rb', line 24 def edit @appraisal = scoped.find(params[:id]) end |
#new ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/hr_lite/admin/appraisals_controller.rb', line 6 def new @appraisal = Appraisal.new( user_id: @profile.user_id, period_start: Date.current.beginning_of_year, period_end: Date.current ) end |
#share ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'app/controllers/hr_lite/admin/appraisals_controller.rb', line 37 def share appraisal = scoped.find(params[:id]) appraisal.share!(actor: hr_current_user) redirect_to admin_employee_path(@profile), notice: "Appraisal shared with the employee." rescue ActiveRecord::RecordInvalid => e = e.record.errors..to_sentence.presence || "This appraisal was already shared." redirect_to admin_employee_path(@profile), alert: end |
#update ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'app/controllers/hr_lite/admin/appraisals_controller.rb', line 28 def update @appraisal = scoped.find(params[:id]) if @appraisal.update(appraisal_params) redirect_to admin_employee_path(@profile), notice: "Appraisal updated." else render :edit, status: :unprocessable_entity end end |