rewrite nested path

Hi there,     I got 2 controllers : Products & ProductReviews. When they are nested, it looks ugly:     /products/:product_id/product_reviews     I want it looks better :     /products/:product_id/reviews

So i wrote this route, but not helper path are available (product_new_product_review...) :

map.resources :products,   :collection => {...},   :has_many => [...] do |products|    products.resources :reviews, :controller => 'product_reviews', :name_prefix => 'product_' end

    What did i do wrong

eeeew! What is this “product_reviews” thing? Rename it to just reviews and then:

map.resources :products do |product| product.resources :reviews, :name_prefix => “product_” end

In Rails 2.0 you don’t need to specify the name_prefix.

Take note of the singular “product” instead of “products” in the block specification.

hi ryan, my problem is i have others review type: user_reviews, store_reviews... so i can't have a "simple" review controller.

because in DB, we made choice to separate reviews in distinct table product_reviews, user_reviews... my controllers are like my db. So i solve this problem by doing it :

map.resources :products do |products|     products.product_product_reviews 'reviews',       :controller => 'product_reviews', :action => 'index',       :conditions => { :method => :get }, :name_prefix => nil     products.new_product_product_review 'reviews/new',       :controller => 'product_reviews', :action => 'new',       :conditions => { :method => :get }, :name_prefix => nil     ... end

Thanx anyway ryan.

I’ll re-iterate the point one last time: Using types on your table and specifying the type as “Product” or “User” will eliminate a lot of the stress you’re going to run into later on when you try to alter something for all reviews. Having just the ONE review controller for every type of review is BEST PRACTICE and is much easier to maintain than having (from what I can see), 4 controllers and 4 models.

ok, i'll remember your advice. my db admin choose this solution (separate tables) because the tables are supposed to become really big in production (i don't remember his arguments... but sometime denormalize could be good). and the other point is that there is table inheritance it was simple to do it like it (even if there is already inheritance in my models). regards and thanks for you interest.

Fire your db admin and hire a chimpanzee. It will do a better job.

? excuse me? i think you should take care of your language.

I take fine care of my language, more so than other purveyors of it who tend to massacre it.

I was simply noting that if your database administration thinks that having multiple tables that he is insane. My basis for this belief has already been stated clearly, I think.

Chimpanzees are fairly cheap and will work for food scraps.