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 ⇒ Object
readonly
Returns the value of attribute admin.
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 ⇒ Object (readonly)
Returns the value of attribute admin.
7 8 9 |
# File 'app/controllers/admin/admin_users_controller.rb', line 7 def admin @admin end |
Instance Method Details
#archive ⇒ Object
53 54 55 56 57 |
# File 'app/controllers/admin/admin_users_controller.rb', line 53 def archive Admin::User.where(id: params[:id]).where.not(id: current_admin.id).each(&:archive!) redirect_back(fallback_location: admin_admin_users_path, status: :see_other) end |
#archived ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/admin/admin_users_controller.rb', line 15 def archived collection = Collection.new.with_params(params).apply(Admin::User.archived.strict_loading) render locals: { collection: } end |
#create ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/admin/admin_users_controller.rb', line 35 def create admin = Admin::User.new(admin_user_params) if admin.save redirect_to admin_admin_user_path(admin) else render :new, locals: { admin: }, status: :unprocessable_content end end |
#destroy ⇒ Object
65 66 67 68 69 |
# File 'app/controllers/admin/admin_users_controller.rb', line 65 def destroy admin.destroy redirect_to admin_admin_users_path end |
#edit ⇒ Object
31 32 33 |
# File 'app/controllers/admin/admin_users_controller.rb', line 31 def edit render :edit, locals: { admin: } end |
#index ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/admin/admin_users_controller.rb', line 9 def index collection = Collection.new.with_params(params).apply(Admin::User.strict_loading) render locals: { collection: } end |
#new ⇒ Object
25 26 27 28 29 |
# File 'app/controllers/admin/admin_users_controller.rb', line 25 def new @admin = Admin::User.new render :new, locals: { admin: } end |
#restore ⇒ Object
59 60 61 62 63 |
# File 'app/controllers/admin/admin_users_controller.rb', line 59 def restore Admin::User.archived.where(id: params[:id]).each(&:restore!) redirect_back(fallback_location: admin_admin_users_path, status: :see_other) end |
#show ⇒ Object
21 22 23 |
# File 'app/controllers/admin/admin_users_controller.rb', line 21 def show render :show, locals: { admin: } end |
#update ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/controllers/admin/admin_users_controller.rb', line 45 def update if admin.update(admin_user_params) redirect_to action: :show else render :edit, locals: { admin: }, status: :unprocessable_content end end |