Question

Is there a way to "wrap" an existing rails 4 routing from a rails engine into a routing scope like described here: Rails routes with optional scope ":locale" ?

I want to use the spree gem (https://github.com/spree/spree) and insert the current locale as the leftmost part of the path, like /en/products/t-shirt

Was it helpful?

Solution

You should be able to do it the same way:

Sandbox::Application.routes.draw do
  scope "(:locale)", locale: /en|fr/ do
    mount Spree::Core::Engine, :at => '/'
  end
end

You'll need to do more work to tie this locale in to Spree's locale, but that's a good place to start.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top