Module: Clearance::UsersController::InstanceMethods

Defined in:
lib/clearance/app/controllers/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @user = User.new params[:user]
  if @user.save
    current_user = @user
    flash[:notice] = "User created and logged in."
    redirect_back_or root_url
  else
    render :action => "new"
  end
end

#destroyObject



58
59
60
61
62
# File 'lib/clearance/app/controllers/users_controller.rb', line 58

def destroy
  @user = User.find params[:id]
  @user.destroy
  redirect_to root_url
end

#editObject



43
44
45
# File 'lib/clearance/app/controllers/users_controller.rb', line 43

def edit
  @user = User.find params[:id]
end

#indexObject



20
21
22
# File 'lib/clearance/app/controllers/users_controller.rb', line 20

def index
  @users = User.find :all
end

#newObject



24
25
26
# File 'lib/clearance/app/controllers/users_controller.rb', line 24

def new
  @user = User.new
end

#showObject



28
29
30
# File 'lib/clearance/app/controllers/users_controller.rb', line 28

def show
  @user = User.find params[:id]
end

#updateObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/clearance/app/controllers/users_controller.rb', line 47

def update
  @user = User.find params[:id]
  
  if @user.update_attributes params[:user]
    flash[:notice] = "User updated."
    redirect_back_or root_url
  else
    render :action => "edit"
  end
end