Class: Munificent::Admin::UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
# File 'app/controllers/munificent/admin/users_controller.rb', line 14

def create
  if @user.save
    flash[:notice] = "User created"
    redirect_to edit_user_path(@user)
  else
    flash[:alert] = @user.errors.full_messages.join(", ")
    redirect_to new_user_path
  end
end

#destroyObject



41
42
43
44
# File 'app/controllers/munificent/admin/users_controller.rb', line 41

def destroy
  @user.destroy
  redirect_to users_path
end

#editObject



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

def edit; end

#indexObject



6
7
8
# File 'app/controllers/munificent/admin/users_controller.rb', line 6

def index
  authorize!(:read, :user_accounts)
end

#newObject



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

def new; end

#showObject



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

def show; end

#updateObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/munificent/admin/users_controller.rb', line 24

def update
  model = :user
  if params[model][:password].blank?
    %w[password password_confirmation].each { |p| params[model].delete(p) }
  end

  @user.assign_attributes(user_params)

  if @user.save
    flash[:notice] = "User saved"
  else
    flash[:alert] = @user.errors.full_messages.join(", ")
  end

  redirect_to edit_user_path(@user)
end