Class: HrLite::KudosController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- HrLite::KudosController
- Defined in:
- app/controllers/hr_lite/kudos_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/hr_lite/kudos_controller.rb', line 8 def create @kudo = Kudo.new(kudo_params.merge(giver: hr_current_user)) if @kudo.save @kudo.register_mentions! redirect_to kudos_path, notice: "Kudos posted." else @kudos = paginate(Kudo.recent.includes(:giver, kudo_mentions: :user)) render :index, status: :unprocessable_entity end end |
#destroy ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/hr_lite/kudos_controller.rb', line 19 def destroy kudo = Kudo.find(params[:id]) if kudo.deletable_by?(hr_current_user) kudo.destroy! redirect_to kudos_path, notice: "Kudos removed.", status: :see_other else redirect_to kudos_path, alert: "You can only remove your own kudos within 15 minutes.", status: :see_other end end |