ActionController::Caching::Sweeper not autoloading in 2.3.0 RC1


#1

Just updated to 2.3.0 RC1 and I’m finding that my sweepers are
throwing NameErrors (uninitialized constant
ActionController::Caching::Sweeper) when evaluation reaches lines like
this one:

class PostSweeper < ActionController::Caching::Sweeper

This only happens in the development environment, because that’s the
only environment where I have “cache_classes” set to false. Relevant
stack trace is:

vendor/rails/activesupport/lib/active_support/dependencies.rb:440:in
load_missing_constant' vendor/rails/activesupport/lib/active_support/dependencies.rb:80:inconst_missing’
app/sweepers/post_sweeper.rb:1
vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in
load_without_new_constant_marking' vendor/rails/activesupport/lib/active_support/dependencies.rb:380:inload_file’
vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in
new_constants_in' vendor/rails/activesupport/lib/active_support/dependencies.rb:379:inload_file’
vendor/rails/activesupport/lib/active_support/dependencies.rb:259:in
require_or_load' vendor/rails/activesupport/lib/active_support/dependencies.rb:425:inload_missing_constant’
vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in
const_missing' vendor/rails/activesupport/lib/active_support/dependencies.rb:92:inconst_missing’
vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb:
43:in const_get' vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb: 43:incache_sweeper’
vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb:
41:in each' vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb: 41:incache_sweeper’
app/controllers/posts_controller.rb:5

I can get rid of the error by manually adding the following at the top
of the sweeper file:

require ‘rails/actionpack/lib/action_controller/caching/sweeping’

But that’s really bizarre, because I can see from the stack trace that
that file has already been evaluated!

Any idea what’s going on here? I created a fresh Rails app and tried
to make a minimal test case but wasn’t able to reproduce, so there’s
something subtle going on.

Cheers,
Wincent


#2

I’ve done a bit more digging and narrowed down the source of the bug.
See:

http://rails.lighthouseapp.com/projects/8994/tickets/1977

Cheers,
Wincent