0
我的想法是,如果您访问www.my-website.com,我想显示一个“选择国家/地区”登录页面,并链接到我的各个国家/地区的网站,例如www。 my-website.dk,www.my-website.de等等,等等Rails:根据域名选择不同的root_to路由
我犯了这样的一个的routes.rb:
MyApp::Application.routes.draw do
constraints subdomain: /\Awww\b/ do
apipie # For API documentation, see initializers/apipie.rb
draw :api_v1_v2_v3
draw :api
constraints ->(request) {request.host =~ /my-website\.com/ } do
root to: 'my_website_dot_com#landing_page' # anyone going to http://www.my-website.com/ will get this action
end
root to: 'my_website#front_page'
get 'sitemap', to: 'my_websiteouncle#sitemap' # anyone going to http://www.my-website.de/ or http://www.my-website.dk/ etc. will get this action
end
end
问题是,我不能有多个root_to
与轨4.2因此如何我可以更改routes.rb来实现这种行为吗?
为什么不加在测试request.url为您的子域名,并相应地重定向应用程序控制器的方法? –