Class: Admin::UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

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

#destroyObject



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

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

#editObject



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

def edit
  respond_with @user
end

#indexObject



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

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



20
21
22
23
# File 'app/controllers/admin/users_controller.rb', line 20

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

#showObject



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

def show
  respond_with @user
end

#updateObject



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

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