我有带有 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.