Class: UsersController

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

Instance Method Summary collapse

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
# File 'app/controllers/users_controller.rb', line 16

def create
  @user = User.new(params[:user])
  if @user.save
    flash[:notice] = "Account registered!"
    redirect_back_or_default user_url(@user)
  else
    render :action => :new
  end
end

#destroyObject



42
43
44
45
46
47
48
49
50
# File 'app/controllers/users_controller.rb', line 42

def destroy
  @user = User.find(params[:id])
  @user.destroy
 
  respond_to do |format|
    format.html { redirect_to(users_url) }
    format.xml { head :ok }
  end
end

#editObject



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

def edit
end

#indexObject



8
9
10
# File 'app/controllers/users_controller.rb', line 8

def index
  @users = User.all
end

#newObject



12
13
14
# File 'app/controllers/users_controller.rb', line 12

def new
  @user = User.new
end

#showObject



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

def show
  require_user if @user.nil?
end

#updateObject



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

def update
  if @user.update_attributes(params[:user])
    flash[:notice] = "Account updated!"
    redirect_to user_url(@user)
  else
    render :action => :edit
  end
end