Class: Manage::AdminsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/manage/admins_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#json_request?, #limit_write_access_to_admins, #logged_in, #require_admin_or_limited_admin, #require_admin_or_limited_admin_or_event_tracking, #response_view_or_errors

Instance Method Details

#create ⇒ Object



26
27
28
29
30
31
32
# File 'app/controllers/manage/admins_controller.rb', line 26

def create
  @user = ::User.new(user_params.merge(password: Devise.friendly_token.first(10)))
  if @user.save
    @user.send_reset_password_instructions
  end
  respond_with(:manage, @user, location: manage_admins_path)
end

#datatable ⇒ Object



10
11
12
# File 'app/controllers/manage/admins_controller.rb', line 10

def datatable
  render json: AdminDatatable.new(view_context)
end

#destroy ⇒ Object



39
40
41
42
# File 'app/controllers/manage/admins_controller.rb', line 39

def destroy
  @user.destroy
  respond_with(:manage, @user, location: manage_admins_path)
end

#edit ⇒ Object



23
24
# File 'app/controllers/manage/admins_controller.rb', line 23

def edit
end

#index ⇒ Object



6
7
8
# File 'app/controllers/manage/admins_controller.rb', line 6

def index
  respond_with(:manage, User.where(role: [:admin, :admin_limited_access, :event_tracking]))
end

#new ⇒ Object



18
19
20
21
# File 'app/controllers/manage/admins_controller.rb', line 18

def new
  @user = ::User.new
  respond_with(:manage, @user)
end

#show ⇒ Object



14
15
16
# File 'app/controllers/manage/admins_controller.rb', line 14

def show
  respond_with(:manage, @user)
end

#update ⇒ Object



34
35
36
37
# File 'app/controllers/manage/admins_controller.rb', line 34

def update
  @user.update_attributes(user_params)
  respond_with(:manage, @user, location: manage_admins_path)
end