How to list all startup paths in Rails 3

How do you list all startup paths in Rails 3?

In the Rails console, when I do this, it lists only user paths added to the configuration:

$ rails c Loading development environment (Rails 3.2.9) 1.9.3p194 :001 > MyRailsApp::Application.config.autoload_paths => [] 
+8
ruby-on-rails ruby-on-rails-3 autoload autoloader
source share
3 answers

Update: please refer to Laura using ActiveSupport :: Dependencies.autoload_paths below. I left this answer here as an alternative method.

In Rails::Engine , which is included in the Rails application module, the following method exists:

 def _all_autoload_paths @_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq end 

So you can either do:

 (MyRailsApp::Application.config.autoload_paths + MyRailsApp::Application.config.eager_load_paths + MyRailsApp::Application.config.autoload_once_paths).uniq 

or

 [:autoload_paths, :eager_load_paths, :autoload_once_paths].collect{|m|MyRailsApp::Application.config.send(m)}.flatten.uniq 

or simply:

 MyRailsApp::Application._all_autoload_paths 

The default result in Rails 3.2.9 is:

 ["/path/to/my_rails_app/app/assets", "/path/to/my_rails_app/app/controllers", "/path/to/my_rails_app/app/helpers", "/path/to/my_rails_app/app/mailers", "/path/to/my_rails_app/app/models"] 

This should include all startup paths that have been added by other gems and custom boot paths.

+16
source share

You can access all startup paths through ActiveSupport::Dependencies.autoload_paths

Call it from the console or run rails r 'puts ActiveSupport::Dependencies.autoload_paths' from the command line.

More details here (for Rails 4, but this also applies to Rails 3): http://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoload-paths

+13
source share
 Rails.application.instance_variable_get(:"@_all_autoload_paths") 
0
source share

All Articles