Chinaunix首页 | 论坛 | 博客
  • 博客访问: 446179
  • 博文数量: 750
  • 博客积分: 40000
  • 博客等级: 大将
  • 技术积分: 4970
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-09 12:36
文章分类

全部博文(750)

文章存档

2011年(1)

2008年(749)

我的朋友
最近访客
[2]

分类:

2008-09-09 15:17:16

class PeopleController < ApplicationController
  def index
    list
    render :action => 'list'
  end
  # GETs should be safe (see  
)
  verify :method => :post, :only => [ :destroy, :create, :update 
],
         :redirect_to => { :action => :list }
  def list
    @person_pages, @people = paginate :people, :per_page => 10
  end
  def show
    @person = Person.find(params[:id])
  end
  def new
    @person = Person.new
  end
  def create
    @person = Person.new(params[:person])
    if @person.save
      flash[:notice] = 'Person was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end
  def edit
    @person = Person.find(params[:id])
  end
  def update
    @person = Person.find(params[:id])
    if @person.update_attributes(params[:person])
      flash[:notice] = 'Person was successfully updated.'
      redirect_to :action => 'show', :id => @person
    else
      render :action => 'edit'
    end
  end
  def destroy
    Person.find(params[:id])。destroy
    redirect_to :action => 'list'
  end
end
      

--------------------next---------------------

阅读(194) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~