看 rails guides,不太懂
def index
@books = Book.all
end
def show
@book = Book.find_by_id(params[:id])
if @book.nil?
redirect_to :action => :index
end
end
把代码中的 redirct_to 换成 render 会怎样
为什么改成 render "index", :alert => 'Your book was not found!'
就是比较好的代码