Class: HrLite::Admin::LeaveTypesController
- Inherits:
-
LeadershipController
- Object
- HrLite::ApplicationController
- BaseController
- LeadershipController
- HrLite::Admin::LeaveTypesController
- Defined in:
- app/controllers/hr_lite/admin/leave_types_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#destroy ⇒ Object
Types with history cannot be destroyed — deactivate instead.
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'app/controllers/hr_lite/admin/leave_types_controller.rb', line 12 def create @leave_type = LeaveType.new(leave_type_params) if @leave_type.save redirect_to admin_leave_types_path, notice: "Leave type created." else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
Types with history cannot be destroyed — deactivate instead.
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/hr_lite/admin/leave_types_controller.rb', line 35 def destroy leave_type = LeaveType.find(params[:id]) if leave_type.destroy redirect_to admin_leave_types_path, notice: "Leave type removed.", status: :see_other else redirect_to admin_leave_types_path, status: :see_other, alert: "This type has leave history — deactivate it instead." end end |
#edit ⇒ Object
21 22 23 |
# File 'app/controllers/hr_lite/admin/leave_types_controller.rb', line 21 def edit @leave_type = LeaveType.find(params[:id]) end |
#index ⇒ Object
4 5 6 |
# File 'app/controllers/hr_lite/admin/leave_types_controller.rb', line 4 def index @leave_types = LeaveType.order(:position, :id) end |
#new ⇒ Object
8 9 10 |
# File 'app/controllers/hr_lite/admin/leave_types_controller.rb', line 8 def new @leave_type = LeaveType.new end |
#update ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/controllers/hr_lite/admin/leave_types_controller.rb', line 25 def update @leave_type = LeaveType.find(params[:id]) if @leave_type.update(leave_type_params) redirect_to admin_leave_types_path, notice: "Leave type updated." else render :edit, status: :unprocessable_entity end end |