简体   繁体   中英

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". I looked it up and I found that I should change the default namespace in "config/initializers/active_admin.rb" to false

config.default_namespace = false

and I surrounded the routes in "routes.rb" with subdomain constraints

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

also, I changed "/etc/hosts" localhost line to be able to test on my machine

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."

The infinite redirect could be because of the Devise configuration. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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