diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 413b308..c248913 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,17 +16,25 @@ class ApplicationController < ActionController::Base class << self # This is necessary for correct devise routing with locales: https://github.com/plataformatec/devise/wiki/How-To:--Redirect-with-locale-after-authentication-failure def default_url_options - locale_options + default = {} + default.merge!(locale_options) + default.merge!(subdirectory_options) end def locale_options { locale: I18n.locale } end + + def subdirectory_options + { subdirectory: 'mezuro' } + end end # This happens after the *_url *_path helpers def default_url_options - self.class.locale_options + default = {} + default.merge!(self.class.locale_options) + default.merge!(self.class.subdirectory_options) end protected diff --git a/config/routes.rb b/config/routes.rb index 0afeb28..ba44b4c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ Rails.application.routes.draw do - scope "mezuro" do + scope "/(:subdirectory)", subdirectory: /mezuro/ do scope "(:locale)", locale: /en|pt/ do # We need to manually define OmniAuth routes since the automatic generation does not support the dynamic scope devise_for :users, skip: :omniauth_callbacks @@ -40,8 +40,10 @@ Rails.application.routes.draw do # Tutorials get '/tutorials/:name' => 'tutorials#view', as: 'tutorials' - root "home#index" + root "home#index", as: 'locale_root' end + + root "home#index" end # See comment above for devise_for -- libgit2 0.21.2