Nesting a resource under multiple other resources creates unexpected routes.
Reported by BJ Clark | February 25th, 2008 @ 12:05 AM | in 0.9
Nesting a resource under multiple other resources only creates the appropriate named route for the last declaration in the file. This creates unexpected routes.
Example:
Creates these routes:
a call such as url(new_ad) generates a route such as:
/users//ads/new
and a calls such as url(new_ad, :user_id => @current_user.id) generates a route such as:
/users/:id/ads/new
I would think the best way to correct this is for nested resources to create named routes such as "users_new_ad". The other option would be to check the params passed so that url(ad, :category_id => 1, :ad_id => 1) generates:
/categories/:id/ad/1
and url(ad, :user_id => 1, :ad_id => 1) would generate:
/users/1/ad/1
I'm posting this here because I didn't know if anyone was working on this and if no one is, what the general consensus is on the best way to implement it.
Comments and changes to this ticket
-
Ezra Zygmuntowicz February 26th, 2008 @ 10:15 AM
- → State changed from new to open
Yeah this area of routing needs to be cleaned up and formalized a bit. We need to come up with a naming convention and make nested resources get their parent resources prepended to their names.
-
BJ Clark February 26th, 2008 @ 07:30 PM
I'd be happy to work on this if a naming convention could be agreed upon.
-
Yehuda Katz (wycats) February 26th, 2008 @ 08:41 PM
- → Milestone changed from to 0.9
BJ: Want to propose something?
-
BJ Clark February 26th, 2008 @ 08:57 PM
I'm all for sticking to the same naming conventions that rails uses. Seems to make sense to me.
-
-
Yehuda Katz (wycats) February 29th, 2008 @ 11:25 PM
- → State changed from open to resolved
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
