Class: Admin::AdminUsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/admin/admin_users_controller.rb

Defined Under Namespace

Classes: Collection

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#adminObject (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

#createObject



29
30
31
32
33
34
35
36
37
# File 'app/controllers/admin/admin_users_controller.rb', line 29

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_entity
  end
end

#destroyObject



47
48
49
50
51
# File 'app/controllers/admin/admin_users_controller.rb', line 47

def destroy
  admin.destroy

  redirect_to admin_admin_users_path
end

#editObject



25
26
27
# File 'app/controllers/admin/admin_users_controller.rb', line 25

def edit
  render :edit, locals: { admin: }
end

#indexObject



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

#newObject



19
20
21
22
23
# File 'app/controllers/admin/admin_users_controller.rb', line 19

def new
  @admin = Admin::User.new

  render :new, locals: { admin: }
end

#showObject



15
16
17
# File 'app/controllers/admin/admin_users_controller.rb', line 15

def show
  render :show, locals: { admin: }
end

#updateObject



39
40
41
42
43
44
45
# File 'app/controllers/admin/admin_users_controller.rb', line 39

def update
  if admin.update(admin_user_params)
    redirect_to action: :show
  else
    render :edit, locals: { admin: }, status: :unprocessable_entity
  end
end