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
Post a Comment