I am having problems with my destroy method on a nested source product that is bound to Orders.
After trying to destroy the item, I redirect users to my order_products_url. I get the following routing error:
No route matches "/orders/1/products"
My destruction method is as follows:
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
And in routes.rb:
resources :orders do
resources :products, :controller => "products"
end
The reason this confuses me is my update method for products, I am redirecting users to order_products_url correctly without any problems. I do not understand why he works there, but not here.
thank
source
share