Quantcast
Channel: Rails 3 - Nested Resources - Routing - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Rails 3 - Nested Resources - Routing

$
0
0

I'm having issues with my destroy method on a nested source Product, that is tied to Orders.

After attempting to destroy an item, I'm redirecting users to my order_products_url. I receive the following routing error:

No route matches "/orders/1/products"

My destroy method looks like this:

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 }    endend

And in routes.rb:

resources :orders do    resources :products, :controller => "products"  end

The reason why this is confusing me, is for my update method for products, I'm properly redirecting users to the order_products_url without issue. I don't understand why it works there but not here.

Thanks


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>