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!