1
0

roles_controller.rb 692 B

12345678910111213141516171819202122232425262728293031323334
  1. # frozen_string_literal: true
  2. module Admin
  3. class Users::RolesController < BaseController
  4. before_action :set_user
  5. def show
  6. authorize @user, :change_role?
  7. end
  8. def update
  9. authorize @user, :change_role?
  10. @user.current_account = current_account
  11. if @user.update(resource_params)
  12. log_action :change_role, @user
  13. redirect_to admin_account_path(@user.account_id), notice: I18n.t('admin.accounts.change_role.changed_msg')
  14. else
  15. render :show
  16. end
  17. end
  18. private
  19. def set_user
  20. @user = User.find(params[:user_id])
  21. end
  22. def resource_params
  23. params.require(:user).permit(:role_id)
  24. end
  25. end
  26. end