Rails engine: NameError: uninitialized constant Active****. Using require 'active_***' acceptable? -
i'm working rails engine uses activerecord/activejob , getting error:
nameerror: uninitialized constant activejob
to fix this, within engine.rb added require e.g.
require 'active_job' module mymod class engine < ::rails::engine ...
however has been suggested me bad way solve problem , alternative check constant defined instead within affected method call. e.g. if defined?(activejob). less happy solution.
can suggest resources discuss this, suggest why 'require' may bad, or suggest alternate solutions?
edit: should state both solutions fix problem; matter of understanding why within rails engine rails classes (e.g. activerecord/activejob) not available unless explicitly required (which suspect engines dependencies not autoloaded) , how 'best' make them available within engine itself.
Comments
Post a Comment