1

我正在尝试根据子域请求重新路由根路径。我浏览了几篇在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 ......中实现相同的目标吗?

4

3 回答 3

1
I came around the problem using the subdomain-fu gem. Thanks for the help.... :-)
于 2013-10-16T12:51:10.417 回答
0

您在 rails 2.3.x 中没有隐含的此功能,它与 rails 3 一起使用。您始终可以编写自己的方法来进行映射并将这些链接路由到该特定方法并从那里重新路由。

于 2013-10-12T03:14:38.133 回答
0

不,路由器约束是 Rails 3 中的一个新特性。

于 2013-10-12T03:11:17.640 回答