RESTful problems - _url failed to generate

Hey guys,

I am a noob, so hopefully this problem has an easy solution. I am building a simple shopping cart with products that have product categories.

I have set up my routes like the following:

  map.resources :product_categories do |product_categories|     product_categories.resources :products   end

which should get me /product_categories/{:product_category_id}/ products/{:id} (for example)

All of the paths seem to be working except when I click to edit a product. I am using the edit_product_category_product_path(@product_category,@product) method in the link_to. When I click to edit a product with this path, I get the following error message:

product_category_product_url failed to generate from {:action=>"show", :product_category_id=>#<Product id: 2, name: "test 2", item_number: "klagkljga", price: #<BigDecimal:2363a60,'0.4323E2', 8(8)>, description: "HEY!", created_at: "2008-07-15 00:41:02", updated_at: "2008-07-15 00:41:02", product_category_id: 1>, :controller=>"products"}, expected: {:action=>"show", :controller=>"products"}, diff: {:product_category_id=>#<Product id: 2, name: "test 2", item_number: "klagkljga", price: #<BigDecimal:236223c,'0.4323E2',8(8)>, description: "HEY!", created_at: "2008-07-15 00:41:02", updated_at: "2008-07-15 00:41:02", product_category_id: 1>}

In my products controller, I have a private method:

  private

  def load_product_category     @product_category = ProductCategory.find(params[:product_category_id])   end

which I call in before_filter on the controller so that this instance variable is available to all actions

Does anyone have any ideas? I would really appreciate it!

anyone?

How are you doing the link_to?

Try this: edit_product_category_product_path(@product_category.id,@product)

I believe you can also just do:

url_for [@product_category, @product]

if you have your routes set up right. I do this sort of thing all the time fo nested restful routes:

<%= link_to h(@item.name), [ @category, @item ] %>

Sorry guys, for some reason i wasn't getting email updates that anyone had posted anything here. Let me try these out and will let you know! Thanks for your help!