Multiple route aliases in Rails 4 -


i have rails 4 application routes:

resources :users resources :notifications resources :comments ... 

my client asked me have urls in english , spanish. i've been googling , found use path attribute this:

resources :users, path: 'usuarios' resources :notifications, path: 'notificaciones' resources :comments, path: 'comentarios' 

this enables me access /usuarios, /notificaciones, /comentarios when go /users receive no route matches [get] "/users", , need both routes.

i tried following:

['users', 'usuarios'].each |p|     resources :users, path: p end ['notifications', 'notificaciones'].each |p|     resources :notifications, path: p end ['comments', 'comentarios'].each |p|     resources :comments, path: p end 

this worked well, there simpler way this? like:

resources :users, path: ['users', 'usuarios']     


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -