Class: Shoppe::UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @user = Shoppe::User.new(safe_params)
  if @user.save
    redirect_to :users, :flash => {:notice => "User has been created successfully"}
  else
    render :action => "new"
  end
end

#destroyObject

Raises:



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

def destroy
  raise Shoppe::Error, "You cannot remove yourself" if @user == current_user
  @user.destroy
  redirect_to :users, :flash => {:notice => "User has been removed successfully"}
end

#editObject



23
24
# File 'app/controllers/shoppe/users_controller.rb', line 23

def edit
end

#indexObject



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

def index
  @users = Shoppe::User.all
end

#newObject



10
11
12
# File 'app/controllers/shoppe/users_controller.rb', line 10

def new
  @user = Shoppe::User.new
end

#updateObject



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

def update
  if @user.update(safe_params)
    redirect_to [:edit, @user], :flash => {:notice => "User has been updated successfully"}
  else
    render :action => "edit"
  end
end