我正在尝试根据子域请求重新路由根路径。我浏览了几篇在rails 3的路线中提到“约束”的文章,如下所述
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
可以在rails 2.3 ......中实现相同的目标吗?