简体   繁体   中英

can't dynamically add activeadmin gem to autoload_paths

I am using heroku for my main app, but now i have separated it to main_app and admin_app (memory issues).

So i have 2 apps running on the same git repo with no problems.

main_app uses subdomain admin. to resolve admin_app

now i want to save some memory without loading active admin.

i use a group in gemfile

group :admin_app do
  gem 'activeadmin', git: 'https://github.com/activeadmin/activeadmin'
end

and in application.rb when admin_app loaded

 Bundler.require(*Rails.groups,:admin_app) 

Now, i have the admin folder which is located on app/admin gets auto loaded so i have to ignore it or else i get an exception (no active_admin gem on main_app)

i solved it by a simple if statement

if Rails.application.secrets.admin_app

ActiveAdmin.register ForumTopic ....

end

i am looking for a better fix for this problem .

i tried moving admin folder to lib or outside the app folder and then add it to

config.autoload_paths << Rails.root.join('admin')

but i just don't see it get loaded when using

ActiveSupport::Dependencies.autoload_paths

i whould like to hear your ideas, thank's

I couldn't find the reason autoload_paths didn't include my files.

I add active_admin files to 'lib' folder and then conditionally required them when

drawing the active_admin routes.

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