local-ch / lhs

⚛️ REST services accelerator: Rails gem providing an easy, active-record-like interface for http (hypermedia) json services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preload LHS classes breaks rails's model autoloading

fpellanda opened this issue · comments

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