class UsersController

Public Instance Methods

create() click to toggle source

POST /users POST /users.json

# File app/controllers/users_controller.rb, line 42
def create
  @user = User.new(params[:user])

  respond_to do |format|
    if @user.save
      format.html { redirect_to @user, :notice => 'User was successfully created.' }
      format.json { render :json => @user, :status => :created, :location => @user }
    else
      format.html { render :action => "new" }
      format.json { render :json => @user.errors, :status => :unprocessable_entity }
    end
  end
end
destroy() click to toggle source

DELETE /users/1 DELETE /users/1.json

# File app/controllers/users_controller.rb, line 74
def destroy
  @user = User.find(params[:id])
  @user.destroy

  respond_to do |format|
    format.html { redirect_to users_url }
    format.json { head :ok }
  end
end
edit() click to toggle source

GET /users/1/edit

# File app/controllers/users_controller.rb, line 36
def edit
  @user = User.find(params[:id])
end
index() click to toggle source

GET /users GET /users.json

# File app/controllers/users_controller.rb, line 4
def index
  @users = User.all

  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => @users }
  end
end
new() click to toggle source

GET /users/new GET /users/new.json

# File app/controllers/users_controller.rb, line 26
def new
  @user = User.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json => @user }
  end
end
show() click to toggle source

GET /users/1 GET /users/1.json

# File app/controllers/users_controller.rb, line 15
def show
  @user = User.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.json { render :json => @user }
  end
end
update() click to toggle source

PUT /users/1 PUT /users/1.json

# File app/controllers/users_controller.rb, line 58
def update
  @user = User.find(params[:id])

  respond_to do |format|
    if @user.update_attributes(params[:user])
      format.html { redirect_to @user, :notice => 'User was successfully updated.' }
      format.json { head :ok }
    else
      format.html { render :action => "edit" }
      format.json { render :json => @user.errors, :status => :unprocessable_entity }
    end
  end
end