0
我有一個Ruby on Rails 4
網站,我希望在domain.com
和mysubdomain.domain.com
中拆分。我正在使用lvh.me
進行測試。子域參數在我的鏈接中被忽略,所以所有鏈接都預先加上了request.subdomain
我的路線文件:
MyApp::Application.routes.draw do
scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
get "first_page" => "pages#first_page", :as => :first_page
constraints subdomain: "mysubdomain" do
get "second_page" => "pages#second_page", :as => :second_page
end
root :to => 'pages#index'
end
end
在我看來,我的文件有:
= link_to "First page", first_page_path
= link_to "Second page", second_page_path(:subdomain => "mysubdomain")
但subdomain
說法顯然忽略。相反,所有鏈接都會預先加入request.subdomain
。
因此,如果例如我在:
http://mysubdomain.lvh.me:3000/second_page
然後在網頁上的鏈接如下:
http://mysubdomain.lvh.me:3000/first_page # Not as intended
http://mysubdomain.lvh.me:3000/second_page # As intended
如何解決這一問題?