1

这不起作用:

get '/' => 'addresses#show', :constraints => Subdomain

库/子域.rb:

class Subdomain  
  def self.matches?(request)  
    request.subdomain.present? && request.subdomain != 'www'  
  end  
end

这条路线被忽略了......

谢谢你

4

2 回答 2

2

Solution:

the specified route has to go before

root to: 'home#index' 
于 2013-04-13T14:17:42.293 回答
0

这工作得很好,只有你需要在你的路由中手动添加 subdomain.rb

get '/' => 'addresses#show', :constraints => Subdomain

库/子域.rb:

class Subdomain  
  def self.matches?(request)  
    request.subdomain.present? && request.subdomain != 'www'  
  end  
end

添加routes.rb

  require 'subdomain'

是的,指定的路线必须先走

root to: 'home#index' 
于 2015-02-26T09:01:49.413 回答