Class: HrLite::ResignationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- HrLite::ResignationsController
- Defined in:
- app/controllers/hr_lite/resignations_controller.rb
Overview
Employee self-service resignation: submit, see status, withdraw while pending. Always scoped to hr_current_user.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/hr_lite/resignations_controller.rb', line 10 def create @resignation = Resignation.new(resignation_params.merge(user_id: hr_current_user.id)) if @resignation.save redirect_to resignation_path, notice: "Resignation submitted — leadership has been notified." else @new_resignation = @resignation render :show, status: :unprocessable_entity end end |
#show ⇒ Object
5 6 7 8 |
# File 'app/controllers/hr_lite/resignations_controller.rb', line 5 def show @resignation = own.recent_first.first @new_resignation = Resignation.new(proposed_last_day: Date.current + 30) unless @resignation&.pending? end |
#withdraw ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/hr_lite/resignations_controller.rb', line 20 def withdraw resignation = own.pending.first if resignation resignation.withdraw!(actor: hr_current_user) redirect_to resignation_path, notice: "Resignation withdrawn." else redirect_to resignation_path, alert: "Nothing pending to withdraw." end end |