我最近在我的 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 中进行子域路由,或者是否有需要配置的设置。