如何重命名rails中的默认REST路由?

Eri*_*edo 1 routing ruby-on-rails

最重要的是,这个问题是关于Rails 2.x.

我住在一个西班牙语国家,我的网络应用程序的URL应该是西班牙语.到目前为止,我总是为我的控制器创建西班牙语拼写动作,但这只是关闭了使用REST的许多优点,比如内置的PUT method => edit action东西.

所以,我想知道如何修改routes.rb文件重定向所有的流量我的现有和未来的资源,又不失REST风格的执行标准.

这可能吗?

示例:

POST /inmuebles
:controller => inmuebles, :action => create

GET /inmuebles
:controller => inmuebles, :action => index

GET /inmuebles/nuevo
:controller => inmuebles, :action => new
Run Code Online (Sandbox Code Playgroud)

Pet*_*own 5

小猪退出了Andrew V的回答,但无法预览我的评论......

由于您的所有资源都可能具有需要相同路径名的相同操作,因此您可以使用with_options块为所有路径设置这些.

例如:

map.with_options :path_names => {:new => 'nuevo', :edit => 'editar'} do |rt|
  rt.resources :ineubles
  rt.resources :pollos
  rt.resources :gatos
end
Run Code Online (Sandbox Code Playgroud)