尝试重新创建脚本/生成scaffold,我已经学习了很多Rails基础知识。我怀疑我需要在某个地方配置默认的产品URL。但我该在哪里做呢?
设置:
-
有:
def edit@product=product.find(params[:id])
-
有
Endo.Eng.Erb
,并将编辑表单发布到
操作=>:创建
-
有
定义创建…}
,代码重定向到(@product,…)
-
获取错误:
未定义<productsController的“product_url”方法: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