1
尝试重新创建{script/generate scaffold},并且我已经获得了许多Rails基础知识。我怀疑我需要在某处配置默认产品网址。但我在哪里做这个?如何设置我的@ product = Product.find(params [:id])以拥有product_url?
设置:
- 有:DEF编辑{@产物= Product.find(PARAMS [:ID])}
- 有无edit.html.erb,具有编辑形式张贴到行动=>:创建
- 有无DEF创建{...},与代码redirect_to的(@product,...)
- 四处错误:未定义的方法`product_url”为#<的ProductsController:0x56102b0>
我DEF更新:
def update
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
end
ohh,这是你谁回答了这个问题:) – 2010-06-16 20:31:36