Class: Admin::UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @user = SpudUser.new(user_params)
  if @user.save
    render 'show', :status => 200
  else
    render 'new', :status => 422
  end
end

#destroyObject



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

def destroy
  @user.destroy
  respond_with @user, :location => admin_users_path
end

#editObject



44
45
46
# File 'app/controllers/admin/users_controller.rb', line 44

def edit
  respond_with @user
end

#indexObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/admin/users_controller.rb', line 9

def index
  @users = SpudUser.order('login asc')
  if params[:search]
    @users = @users.where_name_like(params[:search])
  end
  @users = @users.paginate(:page => params[:page])
  respond_with @users do |format|
    format.html{
      if request.xhr?
        render :partial => 'index'
      else
        render 'index', :layout => 'admin/detail' 
      end
    }
  end
end

#newObject



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

def new
  @user = SpudUser.new
  respond_with @user
end

#showObject



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

def show
  respond_with @user
end

#updateObject



48
49
50
51
# File 'app/controllers/admin/users_controller.rb', line 48

def update
  @user.update_attributes(user_params)
  respond_with @user, :location => admin_user_path(@user), :status => 200
end