'Multiple route aliases in Rails 4

I have a Rails 4 application with some routes:

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

My client asked me to have urls in english and spanish. I've been googling and found that I could use path attribute like this:

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

This enables me to access /usuarios, /notificaciones, /comentarios but when I go to /users I receive No route matches [GET] "/users", and I need both routes.

I tried the following:

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

This worked well, but is there a simpler way to do this? Something like:

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


Solution 1:[1]

Disclamer: an old question, but because it's the first result in Google, I'm answering it now.

You cas use translated paths like this:

scope(path_names: { new: 'neu', edit: 'bearbeiten' }) do
  resources :categories, path: 'kategorien'
end

Source : https://guides.rubyonrails.org/routing.html#translated-paths

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arenzel