2013-10-11 56 views
1

我试图根据子域请求重新路由根路径。我曾通过其在轨道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实现....?

+0

我不是100%确定,但我不这么认为 – phoet

回答

0

没有,路由器限制是Rails中的一项新功能3.

0

你没有这个功能隐式导轨2.3.x版本,它与轨3.您可以编写自己的方法做将这些链接映射并路由到该特定方法并从那里重新路由。

1
I came around the problem using the subdomain-fu gem. Thanks for the help.... :-)