我試圖根據子域請求重新路由根路徑。我曾通過其在軌道3路由提到「約束」的幾篇文章中瀏覽,如下面提到如何在路由中實現約束,爲根的rails 2.3.x
MyKillerApp::Application.routes.draw do |map|
resources :comments
resources :articles
resources :blogs
constraints(Subdomain) do
match '/' => 'blogs#show'
end
root :to => "blogs#index"
end
在lib/subdomain.rb
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != 'www'
end
end
可以在同一個軌道中2.3實現....?
我不是100%確定,但我不這麼認爲 – phoet