我最近在我的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
Run Code Online (Sandbox Code Playgroud)
为了在本地测试子域路由约束,我将此行添加到我的hosts文件中.
127.0.0.1 new.localhost.local
Run Code Online (Sandbox Code Playgroud)
现在,我在浏览器中在URL new.localhost.local:3000上测试我的应用程序.加载每一页大约需要10到15秒,这非常慢.如果我删除了子域约束并且只是转到127.0.0.1:3000,那么一切都是快速且快速的.
我究竟做错了什么?我是Rails的新手,所以请告诉我是否有更好的方法在rails中进行子域路由,或者是否有需要配置的设置.