这不起作用:
get '/' => 'addresses#show', :constraints => Subdomain
LIB / subdomain.rb:
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != 'www'
end
end
这条路线被忽略......
谢谢
答案 0 :(得分:2)
<强>解决方案:强>
指定的路线必须先行
root to: 'home#index'
答案 1 :(得分:0)
只有您需要手动在路线中添加subdomain.rb
,这才能完美运行get '/' => 'addresses#show', :constraints => Subdomain
LIB / subdomain.rb:
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != 'www'
end
end
添加routes.rb
require 'subdomain'
是的,指定的路线必须先行
root to: 'home#index'