Class: Staff::UsersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/staff/users_controller.rb

Overview

Staff-only CRUD functions for Users

Instance Method Summary collapse

Instance Method Details

#destroyObject



27
28
29
30
31
32
33
34
35
# File 'app/controllers/staff/users_controller.rb', line 27

def destroy
  user.update_attribute(:active, false)
  msg = "Archived #{user}"
  redirect_to staff_users_path, notice: msg
rescue ActiveRecord::DeleteRestrictionError => e
  msg = "Unable to archive '#{user}' due to '#{e}'"
  logger.error msg
  redirect_to staff_user_path(user), alert: msg
end

#editObject



15
16
# File 'app/controllers/staff/users_controller.rb', line 15

def edit
end

#indexObject



8
9
10
# File 'app/controllers/staff/users_controller.rb', line 8

def index
  self.users = User.sorted
end

#showObject



12
13
# File 'app/controllers/staff/users_controller.rb', line 12

def show
end

#updateObject



18
19
20
21
22
23
24
25
# File 'app/controllers/staff/users_controller.rb', line 18

def update
  if user.update(user_params)
    redirect_to staff_user_path(user), notice: 'User was successfully updated'
  else
    logger.warn "Unable to update #{user}: #{user.error_sentence}"
    render :edit
  end
end