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

**URL:** <https://www.ruby-forum.com/t/actioncontroller-sweeper-not-autoloading-in-2-3-0-rc1/159449>\
**Category:** Rails\
**Created:** [February 4, 2009, 5:51pm UTC](https://www.ruby-forum.com/t/actioncontroller-sweeper-not-autoloading-in-2-3-0-rc1/159449 "2009-02-04T17:51:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [February 4, 2009, 5:51pm UTC](https://www.ruby-forum.com/t/actioncontroller-sweeper-not-autoloading-in-2-3-0-rc1/159449/1 "2009-02-04T17:51:02Z")

</div>

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:in`const\_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:in`load\_file’  
vendor/rails/activesupport/lib/active\_support/dependencies.rb:521:in  
`new_constants_in' vendor/rails/activesupport/lib/active_support/dependencies.rb:379:in`load\_file’  
vendor/rails/activesupport/lib/active\_support/dependencies.rb:259:in  
`require_or_load' vendor/rails/activesupport/lib/active_support/dependencies.rb:425:in`load\_missing\_constant’  
vendor/rails/activesupport/lib/active\_support/dependencies.rb:80:in  
`const_missing' vendor/rails/activesupport/lib/active_support/dependencies.rb:92:in`const\_missing’  
vendor/rails/actionpack/lib/action\_controller/caching/sweeping.rb:  
43:in `const_get' vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb: 43:in`cache\_sweeper’  
vendor/rails/actionpack/lib/action\_controller/caching/sweeping.rb:  
41:in `each' vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb: 41:in`cache\_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

---

<div class="post-metadata">

**Author:** ![Wincent\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@Wincent\_C](https://www.ruby-forum.com/u/Wincent_C)\
**Post date:** [February 15, 2009, 7:48pm UTC](https://www.ruby-forum.com/t/actioncontroller-sweeper-not-autoloading-in-2-3-0-rc1/159449/2 "2009-02-15T19:48:00Z")

</div>

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

[#1977 ActionController::Caching::Sweeper autoloading is broken - Ruby on Rails - rails](http://rails.lighthouseapp.com/projects/8994/tickets/1977)

Cheers,  
Wincent
