Class: Admin::UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



34
35
36
37
# File 'app/controllers/admin/users_controller.rb', line 34

def create
  @user = SpudUser.create(user_params)
  respond_with @user, :location => admin_users_path
end

#destroyObject



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

def destroy
  @user.destroy
  respond_with @user, :location => admin_users_path do |format|
    format.js{
      render :nothing => true, :status => 200
    }
  end
end

#editObject



39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/admin/users_controller.rb', line 39

def edit
  respond_with @user do |format|
    format.html{
      if request.xhr?
        render 'edit', :layout => false
      else
        render 'edit'
      end
    }
  end
end

#indexObject



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

def index
  @spud_users = SpudUser.ordered.paginate(:page => params[:page], :per_page => 15)
  if params[:search]
    @spud_users = @spud_users.where_name_like(params[:search])
  end
  respond_with @spud_users
end

#newObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/admin/users_controller.rb', line 21

def new
  @user = SpudUser.new
  respond_with @user do |format|
    format.html{
      if request.xhr?
        render 'new', :layout => false
      else
        render 'new'
      end
    }
  end
end

#showObject



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

def show
  respond_with @user
end

#updateObject



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

def update
  if @user.update_attributes(user_params)
    if @user == current_user && user_params[:password].present?
      SpudUserSession.create(@user)
    end
  end
  respond_with @user, :location => admin_user_path(@user), :status => 200
end