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.

Um, why not? You could set a type field on the reviews table and set it
to
User and Store… it’s not that hard to do.

On Jan 24, 2008 9:42 AM, Jean-Sébastien [email protected]
wrote:

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.


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

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.

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.

On Jan 24, 2008 12:30 PM, Jean-Sébastien [email protected]
wrote:

 :controller => 'product_reviews', :action => 'new',

On Jan 24, 12:08 am, “Ryan B.” [email protected] wrote:

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


Ryan B.http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

? 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.

On Jan 24, 2008 4:18 PM, Jean-Sébastien [email protected]
wrote:

I’ll re-iterate the point one last time: Using types on your table
can

Thanx anyway ryan.

reviews
the


Ryan B.http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

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

On Jan 24, 2008 2:38 PM, Jean-Sébastien [email protected]
wrote:

specifying the type as “Product” or “User” will eliminate a lot of the

 :controller => 'product_reviews', :action => 'index',

Um, why not? You could set a type field on the reviews table and set

In Rails 2.0 you don’t need to specify the name_prefix.
Ryan B.http://www.frozenplague.net
Feel free to add me to MSN and/or GTalk as this email.


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.