Heroku雪松,Rails 3.1rc6,子域路由 [英] Heroku cedar, Rails 3.1rc6, subdomain routing
问题描述
在本地,在Unicorn上,我的子域设置工作正常。我已将 heroku子域名文档添加到该信件中,并且还有子域名 Railscast 。 subdomain.lvh.me:3000指向正确的位置,并且lvh.me:3000正确指向在routes.rb中定义的根:
Locally, on Unicorn, my subdomain setup works fine. I've followed the heroku subdomain docs to the letter, and also the subdomains Railscast. subdomain.lvh.me:3000 points to the right place, and lvh.me:3000 points correctly to the root defined in routes.rb:
root :to => "pages#home"
然而,在Heroku的Cedar堆栈的新分段部署中,再次使用Unicorn,而subdomain.mydomain.co.uk指向正确的地方,mydomain.co.uk没有。根据路径文件,它不会访问页面#home,而是按照书籍控制器,它只是在url中包含子域时按照routes.rb执行操作:
However, in my new staging deployment on Heroku's Cedar stack, again using Unicorn, whilst subdomain.mydomain.co.uk points to the right place, mydomain.co.uk doesn't. Instead of going to pages#home as per the routes file, it's hitting the books controller, which it's only meant to do if there's a subdomain in the url, as per routes.rb:
constraints(Subdomain) do
match '/' => 'books#show'
end
我的DNS设置与Heroku文档相同,主机命令返回文档应该说的内容。有任何想法吗?
My DNS settings are as per the Heroku docs, and the host command returns what the docs say it should. Any ideas?
推荐答案
将别名域添加到subdomain.rb:
Add the aliased domain to subdomain.rb:
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != "www" && request.subdomain != "nameofmydomain"
end
end
这篇关于Heroku雪松,Rails 3.1rc6,子域路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!