Heroku cedar, Rails 3.1rc6, subdomain routing

纵然是瞬间 提交于 2019-12-05 02:50:22

问题


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"

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   

My DNS settings are as per the Heroku docs, and the host command returns what the docs say it should. Any ideas?


回答1:


Add the aliased domain to subdomain.rb:

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


来源:https://stackoverflow.com/questions/7151837/heroku-cedar-rails-3-1rc6-subdomain-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!