Preload LHS classes breaks rails's model autoloading
fpellanda opened this issue · comments
Flavio Pellanda commented
LHS should not require classes on server startup when config.cache_classes = false
# lib/lhs.rb
# Preload all the LHS::Records that are defined in app/models
class Engine < Rails::Engine
initializer 'Load all LHS::Records from app/models/**' do |app|
Dir.glob(app.root.join('app/models/**/*.rb')).each do |file|
require file if File.read(file).match('LHS::Record')
end
end
end
If this is really required, load these classes before each request when config.cache_classes = false