Class: Admin::UsersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/admin/users_controller.rb', line 16

def create
  @user = User.new(params[:user])
  @user.memberships.build(:site => @site) if @site and !@user.admin?

  if @user.save
    @user.verify! # TODO hu??
    trigger_events(@user)
    redirect_to [:admin, @user], notice: "The user has been created."
  else
    flash.now.alert = "The user could not be created."
    render :action => :new
  end
end

#destroyObject



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

def destroy
  if @user.destroy
    trigger_events(@user)
    redirect_to [:admin, :users], notice: "The user has been deleted."
  else
    flash.now.alert = "The user could not be deleted."
    render :action => :edit
  end
end

#editObject



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

def edit
end

#indexObject



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

def index
  @users = User.where(admin: true).to_a + @site.users.to_a
end

#newObject



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

def new
  @user = User.new
end

#showObject



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

def show
end

#updateObject



33
34
35
36
37
38
39
40
41
# File 'app/controllers/admin/users_controller.rb', line 33

def update
  if @user.update(params[:user])
    trigger_events(@user)
    redirect_to [:admin, @user], notice: "The user has been updated."
  else
    flash.now.alert = "The user could not be updated."
    render :action => :edit
  end
end