Class: Admin::UsersController

Inherits:
AdminController show all
Defined in:
app/controllers/admin/users_controller.rb

Instance Attribute Summary

Attributes included from PagesCore::Authentication

#current_user

Instance Method Summary collapse

Methods inherited from PagesCore::AdminController

#redirect, underscore

Methods included from PagesCore::PoliciesHelper

#policy, #verify_policy, #verify_policy_with_proc

Methods included from PagesCore::ProcessTitler

inc_number_of_requests, original_title

Methods included from PagesCore::ErrorRenderer

#render_error

Methods included from PagesCore::Authentication

#authenticate!, #deauthenticate!, #logged_in?

Instance Method Details

#createObject


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

def create
  @user = PagesCore::CreateUserService.call(user_params)
  if @user.valid?
    authenticate!(@user)
    redirect_to admin_default_url
  else
    render action: :new
  end
end

#deactivatedObject


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

def deactivated
  @users = User.deactivated
  @invites = []
end

#delete_imageObject


60
61
62
63
64
65
66
# File 'app/controllers/admin/users_controller.rb', line 60

def delete_image
  @user.image.destroy
  respond_to do |format|
    format.js   { render text: "The profile picture has been deleted." }
    format.html { redirect_to(edit_admin_user_url(@user)) }
  end
end

#destroyObject


53
54
55
56
57
58
# File 'app/controllers/admin/users_controller.rb', line 53

def destroy
  @user = User.find(params[:id])
  flash[:notice] = "User <strong>#{@user.email}</strong> has been deleted"
  @user.destroy
  redirect_to admin_users_url
end

#editObject


41
# File 'app/controllers/admin/users_controller.rb', line 41

def edit; end

#indexObject


10
11
12
13
# File 'app/controllers/admin/users_controller.rb', line 10

def index
  @users = User.activated
  @invites = Invite.all.order("created_at DESC")
end

#loginObject


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

def 
  return unless logged_in?
  redirect_to admin_default_url
end

#newObject


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

def new
  @user = User.new
end

#showObject


39
# File 'app/controllers/admin/users_controller.rb', line 39

def show; end

#updateObject


43
44
45
46
47
48
49
50
51
# File 'app/controllers/admin/users_controller.rb', line 43

def update
  if @user.update(user_params_with_roles)
    flash[:notice] = "Your changed to #{@user.name} were saved."
    redirect_to admin_users_url
  else
    flash.now[:error] = "There were problems saving your changes."
    render action: :edit
  end
end