加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails-3 – 子域约束(Rails 3)使本地服务器(瘦)SO SLOW

发布时间:2020-12-17 03:15:13 所属栏目:百科 来源:网络整理
导读:我最近在我的Rails路由文件中添加了一个子域约束 constraints(:subdomain = 'new') do devise_for :customers do get "/customers/sign_up" = "registrations#new" post "/customers" = "registrations#create" put "/customers/:id" = "registrations#updat
我最近在我的Rails路由文件中添加了一个子域约束

constraints(:subdomain => 'new') do
  devise_for :customers do 
    get "/customers/sign_up" => "registrations#new"
    post "/customers" => "registrations#create"
    put "/customers/:id" => "registrations#update"
  end
  match '/' => 'roxy#index'
  namespace :roxy,:path => '/' do
    resources :customers
    resources :surveys
  end
end

为了在本地测试子域路由约束,我将此行添加到我的hosts文件中.

127.0.0.1       new.localhost.local

现在,我在浏览器中在URL new.localhost.local:3000上测试我的应用程序.加载每一页大约需要10到15秒,这非常慢.如果我删除了子域约束并且只是转到127.0.0.1:3000,那么一切都是快速且快速的.

我究竟做错了什么?我是Rails的新手,所以请告诉我是否有更好的方法在rails中进行子域路由,或者是否有需要配置的设置.

解决方法

弄清楚了.它与Rails或子域或瘦无关.事实证明,与其他unixy-things不同,OS X为mDNS功能保留了.local TLD.对于每个页面,DNS解析在加载我的应用程序之前超时.所以我只是将我的/ etc / hosts文件更改为

127.0.0.1    new.localhost.dev

现在一切都很好.

阅读更多:http://www.justincarmony.com/blog/2011/07/27/mac-os-x-lion-etc-hosts-bugs-and-dns-resolution/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读