Sha256: 233f4f9ec4f47dc3d94448b20dc8e3a9ce2cfd32208b17628e83bd1436e1d58e
Contents?: true
Size: 1001 Bytes
Versions: 4
Compression:
Stored size: 1001 Bytes
Contents
module Renalware class Admin::UsersController < BaseController def index @search = User.search(params[:q]) @users = @search.result(distinct: true) authorize @users end def edit load_user end def update load_user if update_user.call(update_params) redirect_to admin_users_path, notice: t(".success", model_name: "user") else flash.now[:error] = t(".failed", model_name: "user") render :edit end end private def load_user @user = User.find(params[:id]) authorize @user end def update_params roles = Array(Role.fetch(role_ids)) user_params.merge(roles: roles) end def user_params params.require(:user).permit(:approved, :unexpire, :telephone, role_ids: []) end def role_ids (user_params[:role_ids] || []).reject(&:blank?) end def update_user @service ||= System::UpdateUser.new(@user) end end end
Version data entries
4 entries across 4 versions & 1 rubygems