我有Devise gem和i18n的Rails 3.2应用程序。但我想改进一点我的应用程序,并允许用户登录这样的子域:login.my-address.com
。但我无法想象如何做到这一点。我明白我应该以某种方式指出devise/sessions#new
,我尝试了一些对我没用的东西。有没有人创造过这样的解决方案?
我的路线:
scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
resources :articles
resources :photos
...
root :to => 'articles#index'
end
match '*path', to: redirect("/#{I18n.default_locale}/%{path}"), constraints: lambda { |req| !req.path.starts_with? "/#{I18n.default_locale}/" } # i18n.
match '', to: redirect("/#{I18n.default_locale}/articles") # Redirect by default to articles.