Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Routing Heroku cedar,Rails 3.1rc6,子域路由_Routing_Heroku_Ruby On Rails 3.1 - Fatal编程技术网

Routing Heroku cedar,Rails 3.1rc6,子域路由

Routing Heroku cedar,Rails 3.1rc6,子域路由,routing,heroku,ruby-on-rails-3.1,Routing,Heroku,Ruby On Rails 3.1,在本地,在Unicorn上,我的子域设置运行良好。我严格遵守了规则,还有子域。子域.lvh.me:3000点到正确的位置,lvh.me:3000点到routes.rb: root :to => "pages#home" constraints(Subdomain) do match '/' => 'books#show' end 然而,在我在Heroku的Cedar stack上的新登台部署中,再次使用Unicorn,而subdomain.mydomain.co.uk指

在本地,在Unicorn上,我的子域设置运行良好。我严格遵守了规则,还有子域。子域.lvh.me:3000点到正确的位置,lvh.me:3000点到routes.rb:

  root :to => "pages#home"
constraints(Subdomain) do
match '/' => 'books#show'
end   
然而,在我在Heroku的Cedar stack上的新登台部署中,再次使用Unicorn,而subdomain.mydomain.co.uk指向正确的位置,mydomain.co.uk没有。它不是按照routes文件转到pages#home,而是按routes.rb:点击books控制器,这仅在url中有子域时才会执行:

  root :to => "pages#home"
constraints(Subdomain) do
match '/' => 'books#show'
end   

我的DNS设置与Heroku文档一致,host命令返回文档所说的内容。有什么想法吗

将别名域添加到subdomain.rb:

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

嘿@Snowangel,我很高兴你解决了你的问题!您应该将答案粘贴到下面的答案框中,将其从问题中删除,然后将答案标记为“已接受”。这将帮助其他人更容易地找到解决方案:)谢谢:)至少值得投一票