Skip to content

Instantly share code, notes, and snippets.

@nwshane
Created May 25, 2015 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwshane/085fffe0b45ae2a1be21 to your computer and use it in GitHub Desktop.
Save nwshane/085fffe0b45ae2a1be21 to your computer and use it in GitHub Desktop.
Rails.application.routes.draw do
scope ':locale', locale: /#{I18n.available_locales.join("|")}/ do
resources :articles do
collection do
get 'custom_json', constraints: { format: :json }, defaults: { format: :json }
end
end
get "*path", to: redirect("/#{I18n.default_locale}") # handles /en/fake/path/whatever
end
get '', to: redirect("/#{I18n.default_locale}") # handles /
get '*path', to: redirect("/#{I18n.default_locale}/%{path}") # handles /not-a-locale/anything
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment