Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Just ran into this myself today and decided to dive deep.</p> <p>The reason you don't see in <code>ActiveSupport::Dependencies.autoload_paths</code> the paths you're adding to <code>config.autoload_paths</code> in <code>config/application.rb</code> is that they aren't copied over until the application is initialized. See <code>rails/engine.rb</code> in the <code>railties</code> gem:</p> <pre><code>module Rails class Engine &lt; Railtie … # Set the paths from which Rails will automatically load source files, # and the load_once paths. # # This needs to be an initializer, since it needs to run once # per engine and get the engine as a block parameter initializer :set_autoload_paths, :before =&gt; :bootstrap_hook do |app| ActiveSupport::Dependencies.autoload_paths.unshift(*_all_autoload_paths) ActiveSupport::Dependencies.autoload_once_paths.unshift(*_all_autoload_once_paths) # Freeze so future modifications will fail rather than do nothing mysteriously config.autoload_paths.freeze config.eager_load_paths.freeze config.autoload_once_paths.freeze end … def _all_autoload_paths @_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq end … end end </code></pre> <p>Were you by any chance trying to invoke <code>MyClass</code> from within <code>config/application.rb</code> or, even earlier, from a script or module that requires <code>config/application.rb</code>? If so, you'll have to explicitly require the file defining <code>MyClass</code>, e.g.:</p> <pre><code>require File.expand_path('../../somefolder/my_class', __FILE__) # now use MyClass </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload