Sha256: 5cda168fad79c8eb0302821ae9d6dbd32514e7337c754347d71fe848b83385e7
Contents?: true
Size: 1.21 KB
Versions: 8
Compression:
Stored size: 1.21 KB
Contents
module Renalware class Admin::UsersController < BaseController include Renalware::Concerns::Pageable def index query = params.fetch(:q, {}) query[:s] ||= "family_name" search = User .where.not(username: :systemuser) .search(query) users = search.result(distinct: true).page(page).per(per_page) authorize users render locals: { users: users, user_search: search } 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
8 entries across 8 versions & 1 rubygems