Rails 3 named routes

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.

On 26 August 2010 16:06, WSzP [email protected] 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

Thanks a lot, that solved it.