# Recent Routing changes in edge rails?

**URL:** <https://www.ruby-forum.com/t/recent-routing-changes-in-edge-rails/103289>\
**Category:** Rails\
**Created:** [May 3, 2007, 9:16pm UTC](https://www.ruby-forum.com/t/recent-routing-changes-in-edge-rails/103289 "2007-05-03T21:16:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [May 3, 2007, 9:16pm UTC](https://www.ruby-forum.com/t/recent-routing-changes-in-edge-rails/103289/1 "2007-05-03T21:16:03Z")

</div>

Does anyone have a link to where they changed the routing behavior in  
edge rails with in the last 3 weeks? Or can give a brief overview of the  
changes?

Seems for example the below went from:

messages: GET /:user\_id/messages/  
{:action=\>“index”, :controller=\>“messages”}

To this:

user\_messages: GET /:user\_id/messages/  
{:controller=\>“messages”, :action=\>“index”}

This happened between revision 6518 and revision 6654 in edge rails.

Route is defined as:

map.resources :users do |user|  
user.resources :messages, :path\_prefix =\> ‘:user\_id’  
end

Thanks

- John

---

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [May 4, 2007, 5:13am UTC](https://www.ruby-forum.com/t/recent-routing-changes-in-edge-rails/103289/2 "2007-05-04T05:13:34Z")

</div>

> user\_messages: GET /:user\_id/messages/  
> {:controller=\>“messages”, :action=\>“index”}
> 
> This happened between revision 6518 and revision 6654 in edge rails.
> 
> Route is defined as:
> 
> map.resources :users do |user|  
> user.resources :messages, :path\_prefix =\> ‘:user\_id’  
> end

This is done to prevent namespace classes. If you wish to get the old  
behavior, you can do :name\_prefix =\> nil.

The preferred way to do what you’re doing is now:

map.resources :users, :has\_many =\> :messages

---

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [May 4, 2007, 7:26am UTC](https://www.ruby-forum.com/t/recent-routing-changes-in-edge-rails/103289/3 "2007-05-04T07:26:40Z")

</div>

> > map.resources :users, :has\_many =\> :messages
> 
> Ahh, thanks, I see it here now:[http://dev.rubyonrails.org/changeset/6588](http://dev.rubyonrails.org/changeset/6588)
> 
> Can you still specify a :path\_prefix with the new way (has\_many)?

No. If you want to use options outside of the convention, you’ll still  
need to work with a block. The block will remain in place for those  
(presumably rare) instances.

---

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [May 4, 2007, 5:33am UTC](https://www.ruby-forum.com/t/recent-routing-changes-in-edge-rails/103289/4 "2007-05-04T05:33:51Z")

</div>

> > Route is defined as:
> > 
> > map.resources :users do |user|  
> > user.resources :messages, :path\_prefix =\> ‘:user\_id’  
> > end
> 
> This is done to prevent namespace classes. If you wish to get the old  
> behavior, you can do :name\_prefix =\> nil.
> 
> The preferred way to do what you’re doing is now:
> 
> map.resources :users, :has\_many =\> :messages

Ahh, thanks, I see it here now:  
[http://dev.rubyonrails.org/changeset/6588](http://dev.rubyonrails.org/changeset/6588)

Can you still specify a :path\_prefix with the new way (has\_many)?

For example if I wanted the prefix to be :user\_login?

I have not fixed all the routes yet to test this.

Thank you,

- John

---

<div class="post-metadata">

**Author:** ![johnnybutler7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/8491ac/32.png) [@johnnybutler7](https://www.ruby-forum.com/u/johnnybutler7)\
**Post date:** [May 4, 2007, 8:00am UTC](https://www.ruby-forum.com/t/recent-routing-changes-in-edge-rails/103289/5 "2007-05-04T08:00:09Z")

</div>

> The preferred way to do what you’re doing is now:
> 
> map.resources :users, :has\_many =\> :messages

I am digging on this syntax. More terse and make sense in the context  
of Rails/ActiveRecord.

I did get tripped up a bit by the changing of the \_url and \_path  
methods.

[http://tuples.us/2007/05/02/changes-to-nested-resource-routes/](http://tuples.us/2007/05/02/changes-to-nested-resource-routes/)

Jordan
