尝试重新创建{script/Generate支架},我已经了解了许多Rails基础知识。我怀疑我需要在某个地方配置默认产品url。但我该在哪做这个呢?
设置:
ProductsController:0x56102b0>有: def编辑{ @product=Product.find(params:id) }
我的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发布于 2010-06-16 20:25:16
啊,添加/config/routeres.rb行:
map.resources :products并确保将其置于默认值之上:
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'这定义了一个用于给予:产品的urls的系统。
https://stackoverflow.com/questions/3056867
复制相似问题