简体   繁体   English

如何在ActiveAdmin上使用子域

[英]How to use subdomain with ActiveAdmin on rails

I'm trying to access the ActiveAdmin with subdomain "admin.localhost.local:3030" instead of namespace "localhost:3030/admin". 我正在尝试使用子域“ admin.localhost.local:3030”而不是名称空间“ localhost:3030 / admin”访问ActiveAdmin。 I looked it up and I found that I should change the default namespace in "config/initializers/active_admin.rb" to false 我查了一下,发现我应该将“ config / initializers / active_admin.rb”中的默认名称空间更改为false

config.default_namespace = false

and I surrounded the routes in "routes.rb" with subdomain constraints 我用子域约束将“ routes.rb”中的路由包围起来

constraints :subdomain => "admin" do
    ActiveAdmin.routes(self)
end

also, I changed "/etc/hosts" localhost line to be able to test on my machine 另外,我更改了“ / etc / hosts”本地主机行以能够在我的机器上进行测试

127.0.0.1    admin.localhost.local

but for some reason, it still doesn't work. 但由于某种原因,它仍然无法正常工作。 I'm trying to access the subdomain by writing admin.localhost.local:3030 and this is what I get from the browser: "The admin.localhost.local page isn't working. admin.localhost.local redirected you too many times." 我正在尝试通过写admin.localhost.local:3030来访问子域,这是我从浏览器中获得的信息:“ admin.localhost.local页面无法正常工作。admin.localhost.local将您重定向了太多次”。

The infinite redirect could be because of the Devise configuration. 无限重定向可能是由于Devise配置所致。 Try the suggestion here: 在这里尝试建议:

constraints :host => 'admin.spikeatschool.local' do
  ActiveAdmin.routes(self)
  devise_for :admin_users, ActiveAdmin::Devise.config.merge(:path => '')
end

https://github.com/activeadmin/activeadmin/issues/691#issuecomment-8583834 https://github.com/activeadmin/activeadmin/issues/691#issuecomment-8583834

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM