这不起作用:
get '/' => 'addresses#show', :constraints => Subdomain
库/子域.rb:
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != 'www'
end
end
这条路线被忽略了......
谢谢你
这不起作用:
get '/' => 'addresses#show', :constraints => Subdomain
库/子域.rb:
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != 'www'
end
end
这条路线被忽略了......
谢谢你
Solution:
the specified route has to go before
root to: 'home#index'
这工作得很好,只有你需要在你的路由中手动添加 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'