rails/rails — Issue #3969: Using autoload_at
Author: egilburg
Created: 2011-12-13 19:11:14+00:00
State: open

After discovering http://api.rubyonrails.org/classes/ActiveSupport/Autoload.html I thought it'd be nice if we could replace our zillion occurences of:

autoload :Something, 'some_path/something'

with:

autoload_at 'some_path' do
autoload :Something'
end

But I keep getting undefined method autoload_at. I tried digging - ActionSupport::Autoload is being loaded by the time it reaches the above line (I tested by putting a puts 'loaded' in activesupport/lib/active_support/dependencies/autoload.rb and it worked, and also require 'active_support/dependencies/autoload' returned false.

I can only guess that while that file is being loaded, the methods it defined aren't replacing Kernel's default autoloading support. I could try using "extend ActiveSupport::Autoload", but I don't want to do this in every single file that uses autoloading (as mentioned above, our project has a bunch of such files)

I also wasn't able to find any online guides on docs on how to use autoload_at, except the above API link.

Could someone help me with this please? Or is the activesupport's autoload library not intended for public use to begin with?