我遇到的问题与我的销毁方法在嵌套的源产品,这是绑定到订单。Rails 3 - 嵌套的资源 - 路由
试图摧毁一件物品后,我将用户重定向到我的order_products_url。我收到以下错误路由:
No route matches "/orders/1/products"
我破坏方法是这样的:
def destroy
@product = Product.find(params[:id])
@order = Order.find(params[:order_id])
@product.destroy
respond_to do |format|
format.html { redirect_to(order_products_url) }
format.xml { head :ok }
end
end
而且在routes.rb中:
resources :orders do
resources :products, :controller => "products"
end
为什么这是混淆了我的原因,是对于我的产品更新方法,我正确地将用户重定向到order_products_url而没有问题。我不明白为什么它在那里工作,但不在这里。
感谢
两个后缀(_path和_url)在这种情况下工作,这是导致该问题的缺少的参数。奇怪的是 – 2010-12-09 19:56:01
。 _url根本不适合我(只是试过) – sethvargo 2010-12-09 20:01:40