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