看了 Agile Web Develoment with Rails 后,跟着写 Depot 的代码,用 scaffold 生产脚手架。y 有些地方的代码,很不理解,为什么 create 成功后就到了 show.html.erb 呢。
def create
@product = Product.new(params[:product])
respond_to do |format|
if @product.save
format.html { redirect_to @product, notice: 'Product was successfully created.' }
format.json { render json: @product, status: :created, location: @product }
else
format.html { render action: "new" }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end
redirect_to @product,为什么就到了 show.html.erb 呢