简体   繁体   English

无法动态地将activeadmin gem添加到autoload_paths

[英]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). 我正在使用heroku作为我的主应用程序,但现在我将它分离为main_app和admin_app(内存问题)。

So i have 2 apps running on the same git repo with no problems. 所以我有2个应用程序在同一个git仓库上运行,没有任何问题。

main_app uses subdomain admin. main_app使用子域管理员。 to resolve admin_app 解决admin_app

now i want to save some memory without loading active admin. 现在我想保存一些内存而不加载活动管理员。

i use a group in gemfile 我在gemfile中使用一个组

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

and in application.rb when admin_app loaded 在admin_app加载时在application.rb中

 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) 现在,我有app / admin上的admin文件夹自动加载所以我必须忽略它,否则我得到一个异常(main_app上没有active_admin gem)

i solved it by a simple if statement 我用一个简单的if语句解决了它

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 我尝试将管理文件夹移动到lib或app文件夹之外,然后将其添加到

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. 我找不到autoload_paths不包含我的文件的原因。

I add active_admin files to 'lib' folder and then conditionally required them when 我将active_admin文件添加到'lib'文件夹,然后在有条件时需要它们

drawing the active_admin routes. 绘制active_admin路由。

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

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