roles_controller.rb 584 B

123456789101112131415161718192021222324252627
  1. # frozen_string_literal: true
  2. module Admin
  3. class RolesController < BaseController
  4. before_action :set_user
  5. def promote
  6. authorize @user, :promote?
  7. @user.promote!
  8. log_action :promote, @user
  9. redirect_to admin_account_path(@user.account_id)
  10. end
  11. def demote
  12. authorize @user, :demote?
  13. @user.demote!
  14. log_action :demote, @user
  15. redirect_to admin_account_path(@user.account_id)
  16. end
  17. private
  18. def set_user
  19. @user = Account.find(params[:account_id]).user || raise(ActiveRecord::RecordNotFound)
  20. end
  21. end
  22. end