Class: Admin::AdminUsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Admin::AdminUsersController
- Defined in:
- app/controllers/admin/admin_users_controller.rb
Defined Under Namespace
Classes: Collection
Instance Attribute Summary collapse
-
#admin_user ⇒ Object
readonly
Returns the value of attribute admin_user.
Instance Method Summary collapse
- #archive ⇒ Object
- #archived ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #restore ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Attribute Details
#admin_user ⇒ Object (readonly)
Returns the value of attribute admin_user.
8 9 10 |
# File 'app/controllers/admin/admin_users_controller.rb', line 8 def admin_user @admin_user end |
Instance Method Details
#archive ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/admin/admin_users_controller.rb', line 54 def archive Admin::User.where(id: params[:id]).where.not(id: current_admin.id).each(&:archive!) redirect_back_or_to(admin_admin_users_path, status: :see_other) end |
#archived ⇒ Object
16 17 18 19 20 |
# File 'app/controllers/admin/admin_users_controller.rb', line 16 def archived collection = Collection.new.with_params(params).apply(Admin::User.archived.strict_loading) render locals: { collection: } end |
#create ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/admin/admin_users_controller.rb', line 36 def create admin_user = Admin::User.new(admin_user_params) if admin_user.save redirect_to admin_admin_user_path(admin_user) else render :new, locals: { admin_user: }, status: :unprocessable_content end end |
#destroy ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/admin/admin_users_controller.rb', line 66 def destroy return redirect_back_or_to(admin_admin_users_path, status: :see_other) if admin_user == current_admin if admin_user.archived? admin_user.destroy! redirect_to admin_admin_users_path else admin_user.archive! redirect_back_or_to(admin_admin_user_path(admin_user), status: :see_other) end end |
#edit ⇒ Object
32 33 34 |
# File 'app/controllers/admin/admin_users_controller.rb', line 32 def edit render :edit, locals: { admin_user: } end |
#index ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/admin/admin_users_controller.rb', line 10 def index collection = Collection.new.with_params(params).apply(Admin::User.strict_loading) render locals: { collection: } end |
#new ⇒ Object
26 27 28 29 30 |
# File 'app/controllers/admin/admin_users_controller.rb', line 26 def new @admin_user = Admin::User.new render locals: { admin_user: } end |
#restore ⇒ Object
60 61 62 63 64 |
# File 'app/controllers/admin/admin_users_controller.rb', line 60 def restore Admin::User.archived.where(id: params[:id]).each(&:restore!) redirect_back_or_to(admin_admin_users_path, status: :see_other) end |
#show ⇒ Object
22 23 24 |
# File 'app/controllers/admin/admin_users_controller.rb', line 22 def show render locals: { admin_user: } end |
#update ⇒ Object
46 47 48 49 50 51 52 |
# File 'app/controllers/admin/admin_users_controller.rb', line 46 def update if admin_user.update(admin_user_params) redirect_to action: :show else render :edit, locals: { admin_user: }, status: :unprocessable_content end end |