Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 2a9df38332
Fetching contributors…

Cannot retrieve contributors at this time

84 lines (72 sloc) 1.872 kb
# coding: utf-8
class UsersController < ApplicationController
layout 'server'
before_filter :auth_current_user,:except => [:new,:create]
# GET /users
# GET /users.xml
def index
@users = User.paginate(:page => params[:page],:per_page => 10)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @users }
end
end
# GET /users/1
# GET /users/1.xml
def show
@user = User.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @user }
end
end
# GET /users/new
# GET /users/new.xml
def new
@user = User.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @user }
end
end
# GET /users/1/edit
def edit
@user = User.find(params[:id])
end
# POST /users
# POST /users.xml
def create
@user = User.new(params[:user])
if @user.save
#format.html { redirect_to(@user, :notice => 'User was successfully created.') }
flash[:notice] = "注册成功,请登陆..."
redirect_to login_path
else
render :action => "new"
end
end
# PUT /users/1
# PUT /users/1.xml
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.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /users/1
# DELETE /users/1.xml
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
end
Jump to Line
Something went wrong with that request. Please try again.