# Rails 3 named routes

**URL:** <https://www.ruby-forum.com/t/rails-3-named-routes/193924>\
**Category:** Rails\
**Created:** [August 26, 2010, 5:08pm UTC](https://www.ruby-forum.com/t/rails-3-named-routes/193924 "2010-08-26T17:08:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![WSzP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f14d63/32.png) [@WSzP](https://www.ruby-forum.com/u/WSzP)\
**Post date:** [August 26, 2010, 5:08pm UTC](https://www.ruby-forum.com/t/rails-3-named-routes/193924/1 "2010-08-26T17:08:56Z")

</div>

Hello,  
In Rails 2 the following works:  
map.resources :domains, :as =\> ‘domainek’, :path\_names =\> { :new =\>  
‘uj’, :edit =\> ‘szerkesztes’ }  
In Rails 3 what is the good way to do this?  
Basically when I write domainek/uj I want to use the domains  
controller with new, etc.

Well, the straight way of doing it would be:

match ‘domainek/uj’ =\> ‘domains#new’, :as =\> :static  
match ‘domainek/szerkesztes’ =\> ‘domains#edit’, :as =\> :static  
match ‘domainek’ =\> ‘domains’, :as =\> :static

But then new\_domain\_path does not work in the views, plus the above is  
not very rails like.

Can you please tell me what’s the good way of doing it in Rails 3.  
Thank you.

---

<div class="post-metadata">

**Author:** ![WSzP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f14d63/32.png) [@WSzP](https://www.ruby-forum.com/u/WSzP)\
**Post date:** [August 27, 2010, 12:57pm UTC](https://www.ruby-forum.com/t/rails-3-named-routes/193924/2 "2010-08-27T12:57:15Z")

</div>

On 26 August 2010 16:06, WSzP [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> match ‘domainek/uj’ =\> ‘domains#new’, :as =\> :static  
> match ‘domainek/szerkesztes’ =\> ‘domains#edit’, :as =\> :static  
> match ‘domainek’ =\> ‘domains’, :as =\> :static
> 
> But then new\_domain\_path does not work in the views, plus the above is  
> not very rails like.
> 
> Can you please tell me what’s the good way of doing it in Rails 3.  
> Thank you.

The resources method in Rails 3 should still accept the :path\_names  
option. The :as option has been renamed to :path. So this ought to  
work:

resources :domains, :path =\> ‘domainek’, :path\_names =\> { :new =\>  
‘uj’, :edit =\> ‘szerkesztes’ }

Chris

---

<div class="post-metadata">

**Author:** ![WSzP](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/f14d63/32.png) [@WSzP](https://www.ruby-forum.com/u/WSzP)\
**Post date:** [August 27, 2010, 5:51pm UTC](https://www.ruby-forum.com/t/rails-3-named-routes/193924/3 "2010-08-27T17:51:12Z")

</div>

Thanks a lot, that solved it.
