<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <assigned-user-id type="integer">424</assigned-user-id>
  <attachments-count type="integer">2</attachments-count>
  <closed type="boolean">true</closed>
  <created-at type="datetime">2009-02-15T18:45:06+00:00</created-at>
  <creator-id type="integer">12845</creator-id>
  <milestone-due-on type="datetime" nil="true"></milestone-due-on>
  <milestone-id type="integer">9903</milestone-id>
  <number type="integer">1977</number>
  <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
  <priority type="integer">1165</priority>
  <project-id type="integer">8994</project-id>
  <raw-data type="binary" nil="true" encoding="base64"></raw-data>
  <state>resolved</state>
  <tag>2.3.2 patch</tag>
  <title>ActionController::Caching::Sweeper autoloading is broken</title>
  <updated-at type="datetime">2009-06-01T22:44:55+01:00</updated-at>
  <user-id type="integer">11310</user-id>
  <user-name>Andreas Korth</user-name>
  <creator-name>Wincent Colaiuta</creator-name>
  <assigned-user-name>Joshua Peek</assigned-user-name>
  <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
  <milestone-title>2.x</milestone-title>
  <original-body>Originally posted this as a question to the rubyonrails-talk Google group:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/323ff7ec2d95ee32

Quoting from that message:

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 &lt; ActionController::Caching::Sweeper
@@@

This only happens in the development environment, because that's the only environment where I have &quot;cache_classes&quot; 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
@@@

On further digging, I've narrowed things down to commit 31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f, &quot;Use autoload instead of explicit requires for ActionController&quot;.

Basically, when:

@@@
require 'action_controller/caching/sweeping'
@@@

Was ripped out in favor of:

@@@
autoload :Sweeping, 'action_controller/caching/sweeping'
@@@

Things break because the constant in question is not actually &quot;Sweeping&quot; but &quot;Sweeper&quot; (see line 56 of &quot;actionpack/lib/action_controller/caching/sweeping.rb&quot;).

I imagine the issue is relatively common because when you write a sweeper you do it with:

@@@
class PostSweeper &lt; ActionController::Caching::Sweeper
@@@

And don't actually make reference to the &quot;Sweeping&quot; constant mentioned in the autoload line.

The fix? Conservatively I guess the fix is to add another autoload line:

@@@
autoload :Sweeper, 'action_controller/caching/sweeping'
@@@

Alternatively, if you think that nobody actually uses the &quot;Sweeping&quot; module directly, then you could actually replace the existing autoload line with the above.</original-body>
  <latest-body>Originally posted this as a question to the rubyonrails-talk Google group:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/323ff7ec2d95ee32

Quoting from that message:

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 &lt; ActionController::Caching::Sweeper
@@@

This only happens in the development environment, because that's the only environment where I have &quot;cache_classes&quot; 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
@@@

On further digging, I've narrowed things down to commit 31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f, &quot;Use autoload instead of explicit requires for ActionController&quot;.

Basically, when:

@@@
require 'action_controller/caching/sweeping'
@@@

Was ripped out in favor of:

@@@
autoload :Sweeping, 'action_controller/caching/sweeping'
@@@

Things break because the constant in question is not actually &quot;Sweeping&quot; but &quot;Sweeper&quot; (see line 56 of &quot;actionpack/lib/action_controller/caching/sweeping.rb&quot;).

I imagine the issue is relatively common because when you write a sweeper you do it with:

@@@
class PostSweeper &lt; ActionController::Caching::Sweeper
@@@

And don't actually make reference to the &quot;Sweeping&quot; constant mentioned in the autoload line.

The fix? Conservatively I guess the fix is to add another autoload line:

@@@
autoload :Sweeper, 'action_controller/caching/sweeping'
@@@

Alternatively, if you think that nobody actually uses the &quot;Sweeping&quot; module directly, then you could actually replace the existing autoload line with the above.</latest-body>
  <original-body-html>&lt;div&gt;&lt;p&gt;Originally posted this as a question to the rubyonrails-talk
Google group:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/323ff7ec2d95ee32&quot;&gt;
http://groups.google.com/group/r...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Quoting from that message:&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
class PostSweeper &amp;lt; ActionController::Caching::Sweeper
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This only happens in the development environment, because that's
the only environment where I have &quot;cache_classes&quot; set to false.
Relevant stack trace is:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  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
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On further digging, I've narrowed things down to commit
31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f, &quot;Use autoload instead of
explicit requires for ActionController&quot;.&lt;/p&gt;
&lt;p&gt;Basically, when:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
require 'action_controller/caching/sweeping'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Was ripped out in favor of:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
autoload :Sweeping, 'action_controller/caching/sweeping'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Things break because the constant in question is not actually
&quot;Sweeping&quot; but &quot;Sweeper&quot; (see line 56 of
&quot;actionpack/lib/action_controller/caching/sweeping.rb&quot;).&lt;/p&gt;
&lt;p&gt;I imagine the issue is relatively common because when you write
a sweeper you do it with:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
class PostSweeper &amp;lt; ActionController::Caching::Sweeper
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And don't actually make reference to the &quot;Sweeping&quot; constant
mentioned in the autoload line.&lt;/p&gt;
&lt;p&gt;The fix? Conservatively I guess the fix is to add another
autoload line:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
autoload :Sweeper, 'action_controller/caching/sweeping'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, if you think that nobody actually uses the
&quot;Sweeping&quot; module directly, then you could actually replace the
existing autoload line with the above.&lt;/p&gt;&lt;/div&gt;</original-body-html>
  <versions type="array">
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Originally posted this as a question to the rubyonrails-talk Google group:

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/323ff7ec2d95ee32

Quoting from that message:

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 &lt; ActionController::Caching::Sweeper
@@@

This only happens in the development environment, because that's the only environment where I have &quot;cache_classes&quot; 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
@@@

On further digging, I've narrowed things down to commit 31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f, &quot;Use autoload instead of explicit requires for ActionController&quot;.

Basically, when:

@@@
require 'action_controller/caching/sweeping'
@@@

Was ripped out in favor of:

@@@
autoload :Sweeping, 'action_controller/caching/sweeping'
@@@

Things break because the constant in question is not actually &quot;Sweeping&quot; but &quot;Sweeper&quot; (see line 56 of &quot;actionpack/lib/action_controller/caching/sweeping.rb&quot;).

I imagine the issue is relatively common because when you write a sweeper you do it with:

@@@
class PostSweeper &lt; ActionController::Caching::Sweeper
@@@

And don't actually make reference to the &quot;Sweeping&quot; constant mentioned in the autoload line.

The fix? Conservatively I guess the fix is to add another autoload line:

@@@
autoload :Sweeper, 'action_controller/caching/sweeping'
@@@

Alternatively, if you think that nobody actually uses the &quot;Sweeping&quot; module directly, then you could actually replace the existing autoload line with the above.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Originally posted this as a question to the rubyonrails-talk
Google group:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/323ff7ec2d95ee32&quot;&gt;
http://groups.google.com/group/r...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Quoting from that message:&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
class PostSweeper &amp;lt; ActionController::Caching::Sweeper
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This only happens in the development environment, because that's
the only environment where I have &quot;cache_classes&quot; set to false.
Relevant stack trace is:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
  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
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On further digging, I've narrowed things down to commit
31ce92f7b5784bc5b6a441e88cd734c7b8b1c58f, &quot;Use autoload instead of
explicit requires for ActionController&quot;.&lt;/p&gt;
&lt;p&gt;Basically, when:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
require 'action_controller/caching/sweeping'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Was ripped out in favor of:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
autoload :Sweeping, 'action_controller/caching/sweeping'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Things break because the constant in question is not actually
&quot;Sweeping&quot; but &quot;Sweeper&quot; (see line 56 of
&quot;actionpack/lib/action_controller/caching/sweeping.rb&quot;).&lt;/p&gt;
&lt;p&gt;I imagine the issue is relatively common because when you write
a sweeper you do it with:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
class PostSweeper &amp;lt; ActionController::Caching::Sweeper
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And don't actually make reference to the &quot;Sweeping&quot; constant
mentioned in the autoload line.&lt;/p&gt;
&lt;p&gt;The fix? Conservatively I guess the fix is to add another
autoload line:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
autoload :Sweeper, 'action_controller/caching/sweeping'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, if you think that nobody actually uses the
&quot;Sweeping&quot; module directly, then you could actually replace the
existing autoload line with the above.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-15T18:45:06+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag nil="true"></tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-15T18:45:11+00:00</updated-at>
      <user-id type="integer">12845</user-id>
      <user-name>Wincent Colaiuta</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">0</attachments-count>
      <body>Attaching a minimal patch.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Attaching a minimal patch.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-15T18:53:37+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: 
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>2.3.0 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-15T18:53:38+00:00</updated-at>
      <user-id type="integer">12845</user-id>
      <user-name>Wincent Colaiuta</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Sigh, forget that patch I just attached. &quot;autoload&quot; evidently doesn't work like I thought it did.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Sigh, forget that patch I just attached. &quot;autoload&quot; evidently
doesn't work like I thought it did.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-15T19:02:24+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: 2.3.0 patch
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>2.3.0</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-15T19:02:26+00:00</updated-at>
      <user-id type="integer">12845</user-id>
      <user-name>Wincent Colaiuta</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Further digging shows that at the time &quot;actionpack/lib/action_controller/caching/sweeping.rb&quot; is evaluated, the &quot;Sweeper&quot; class can't be defined yet because either ActiveRecord or ActiveRecord::Observer isn't defined yet...

@@@
if defined?(ActiveRecord) and defined?(ActiveRecord::Observer)&#182;
  class Sweeper &lt; ActiveRecord::Observer #:nodoc:&#182;
@@@

If I fire up a &quot;script/console&quot; session, I see &quot;action_controller/caching/sweeping.rb&quot; being immediately evaluated, but ActionController::Caching::Sweeper does not get defined.

If I require &quot;action_controller/caching/sweeping.rb&quot;, nothing is evaluated because the file has already been loaded, so &quot;require&quot; does nothing.

If I force re-evaluation of the file by using a different path in my &quot;require&quot;, './vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb', for instance, then ActionController::Caching::Sweeper does get defined.

So is there any way to change the load order, so that by the time &quot;sweeping.rb&quot; gets evaluated ActiveRecord and ActiveRecord::Observer are defined?</body>
      <body-html>&lt;div&gt;&lt;p&gt;Further digging shows that at the time
&quot;actionpack/lib/action_controller/caching/sweeping.rb&quot; is
evaluated, the &quot;Sweeper&quot; class can't be defined yet because either
ActiveRecord or ActiveRecord::Observer isn't defined yet...&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
if defined?(ActiveRecord) and defined?(ActiveRecord::Observer)&#182;
  class Sweeper &amp;lt; ActiveRecord::Observer #:nodoc:&#182;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I fire up a &quot;script/console&quot; session, I see
&quot;action_controller/caching/sweeping.rb&quot; being immediately
evaluated, but ActionController::Caching::Sweeper does not get
defined.&lt;/p&gt;
&lt;p&gt;If I require &quot;action_controller/caching/sweeping.rb&quot;, nothing is
evaluated because the file has already been loaded, so &quot;require&quot;
does nothing.&lt;/p&gt;
&lt;p&gt;If I force re-evaluation of the file by using a different path
in my &quot;require&quot;,
'./vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb',
for instance, then ActionController::Caching::Sweeper does get
defined.&lt;/p&gt;
&lt;p&gt;So is there any way to change the load order, so that by the
time &quot;sweeping.rb&quot; gets evaluated ActiveRecord and
ActiveRecord::Observer are defined?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-15T19:13:38+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>2.3.0</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-15T19:13:39+00:00</updated-at>
      <user-id type="integer">12845</user-id>
      <user-name>Wincent Colaiuta</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Looking at this, the &quot;correct&quot; (robust) solution seems to be to:

1. Move the Sweeper class out into a separate file, seeing as it depends on ActiveRecord::Observer.
2. Add an &quot;autoload&quot; line for Sweeper, leaving the existing &quot;autoload&quot; for Sweeping in place.
3. In Sweeper's new file, require ActiveRecord/ActiveRecord::Observer.

Sound ok? If so, I can whip up a patch.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Looking at this, the &quot;correct&quot; (robust) solution seems to be
to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Move the Sweeper class out into a separate file, seeing as it
depends on ActiveRecord::Observer.&lt;/li&gt;
&lt;li&gt;Add an &quot;autoload&quot; line for Sweeper, leaving the existing
&quot;autoload&quot; for Sweeping in place.&lt;/li&gt;
&lt;li&gt;In Sweeper's new file, require
ActiveRecord/ActiveRecord::Observer.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Sound ok? If so, I can whip up a patch.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-15T19:38:56+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>2.3.0</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-15T19:39:00+00:00</updated-at>
      <user-id type="integer">12845</user-id>
      <user-name>Wincent Colaiuta</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Ok, I now have a relatively minimal test case that demonstrates the problem.

First up, create a new Rails app with a minimal resource:

@@@
rails demo
cd demo
script/generate resource foo
rake db:migrate
@@@

Set up a sweeper:

@@@
echo &quot;class FooSweeper &lt; ActionController::Caching::Sweeper; end&quot; &gt; app/models/foo_sweeper.rb
@@@

Add a &quot;cache_sweeper&quot; line and a basic index action to the &quot;app/controllers/foos_controller.rb&quot;:

@@@
cache_sweeper :foo_sweeper
def index; end
@@@

Set up the corresponding view template:

@@@
touch app/views/foos/index.html.erb
@@@

To actually trigger the issue, I had to install Haml, so add this line to &quot;config/environment.rb&quot;:

@@@
config.gem 'haml', :version =&gt; '2.0.8'
@@@

And unpack it (I guess this step is optional):

@@@
rake gems:unpack
@@@

Now the critical step... add this to &quot;config/environments/development.rb&quot;:

@@@
Sass::Plugin.options[:always_update] = true
Sass::Plugin.options[:always_check] = true
@@@

It doesn't matter what configuration you actually add in there; the important thing is to access the &quot;Sass::Plugin&quot; constant from inside the environment file...

Now start up the server:

@@@
script/server
@@@

And try hitting a URL like http://localhost:3000/foos

Voila, there's your &quot;Uninitialized constant ActionController::Caching::Sweeper&quot; exception.

I discovered this by printing out a backtrace from within &quot;actionpack/lib/action_controller/caching/sweeping.rb&quot;. Here I could see that:

1. The &quot;sweeping.rb&quot; file was evaluated for the first time because the &quot;sass/plugin.rb&quot; file references ActionController
2. At the time &quot;sweeping.rb&quot; is evaluated, ActiveRecord is already defined by ActiveRecord::Observer is not, so the Sweeper class never gets defined

Here's the backtrace:

@@@
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb:59
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/caching.rb:43:in `included'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/caching.rb:33:in `class_eval'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/caching.rb:33:in `included'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1350:in `include'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1350
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1345:in `each'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1345
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1344:in `class_eval'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1344
    /private/tmp/demo/vendor/gems/haml-2.0.8/lib/sass/plugin/rails.rb:11
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    /private/tmp/demo/vendor/gems/haml-2.0.8/lib/sass/plugin.rb:168
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in `load_file'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:379:in `load_file'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:259:in `require_or_load'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:425:in `load_missing_constant'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
    /private/tmp/demo/config/environments/development.rb:21:in `load_environment'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:356:in `load_environment'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:349:in `load_environment'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:138:in `process'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
    /private/tmp/demo/config/environment.rb:9
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    /private/tmp/demo/vendor/rails/railties/lib/commands/server.rb:82
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3
@@@

So one workaround I have available to me is to drop the Sass configuration from my &quot;config/environments/development.rb&quot; file, and instead put it in an initializer in &quot;config/initializers&quot; inside a conditional &quot;if ENV['RAILS_ENV'] == 'development'&quot; block.

But I think a more robust fix might be to make the changes I suggested in my last comment. Like I said, if someone thinks this is a good idea, please let me know and I'll prepare a patch.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Ok, I now have a relatively minimal test case that demonstrates
the problem.&lt;/p&gt;
&lt;p&gt;First up, create a new Rails app with a minimal resource:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
rails demo
cd demo
script/generate resource foo
rake db:migrate
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Set up a sweeper:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
echo &amp;quot;class FooSweeper &amp;lt; ActionController::Caching::Sweeper; end&amp;quot; &amp;gt; app/models/foo_sweeper.rb
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Add a &quot;cache_sweeper&quot; line and a basic index action to the
&quot;app/controllers/foos_controller.rb&quot;:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
cache_sweeper :foo_sweeper
def index; end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Set up the corresponding view template:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
touch app/views/foos/index.html.erb
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To actually trigger the issue, I had to install Haml, so add
this line to &quot;config/environment.rb&quot;:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
config.gem 'haml', :version =&amp;gt; '2.0.8'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And unpack it (I guess this step is optional):&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
rake gems:unpack
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now the critical step... add this to
&quot;config/environments/development.rb&quot;:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
Sass::Plugin.options[:always_update] = true
Sass::Plugin.options[:always_check] = true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It doesn't matter what configuration you actually add in there;
the important thing is to access the &quot;Sass::Plugin&quot; constant from
inside the environment file...&lt;/p&gt;
&lt;p&gt;Now start up the server:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
script/server
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And try hitting a URL like &lt;a href=&quot;http://localhost:3000/foos&quot;&gt;http://localhost:3000/foos&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Voila, there's your &quot;Uninitialized constant
ActionController::Caching::Sweeper&quot; exception.&lt;/p&gt;
&lt;p&gt;I discovered this by printing out a backtrace from within
&quot;actionpack/lib/action_controller/caching/sweeping.rb&quot;. Here I
could see that:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The &quot;sweeping.rb&quot; file was evaluated for the first time because
the &quot;sass/plugin.rb&quot; file references ActionController&lt;/li&gt;
&lt;li&gt;At the time &quot;sweeping.rb&quot; is evaluated, ActiveRecord is already
defined by ActiveRecord::Observer is not, so the Sweeper class
never gets defined&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Here's the backtrace:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb:59
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/caching.rb:43:in `included'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/caching.rb:33:in `class_eval'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/caching.rb:33:in `included'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1350:in `include'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1350
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1345:in `each'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1345
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1344:in `class_eval'
    /private/tmp/demo/vendor/rails/actionpack/lib/action_controller/base.rb:1344
    /private/tmp/demo/vendor/gems/haml-2.0.8/lib/sass/plugin/rails.rb:11
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    /private/tmp/demo/vendor/gems/haml-2.0.8/lib/sass/plugin.rb:168
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in `load_file'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:379:in `load_file'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:259:in `require_or_load'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:425:in `load_missing_constant'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
    /private/tmp/demo/config/environments/development.rb:21:in `load_environment'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:356:in `load_environment'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:349:in `load_environment'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:138:in `process'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `send'
    ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `run'
    /private/tmp/demo/config/environment.rb:9
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
    /private/tmp/demo/vendor/rails/activesupport/lib/active_support/dependencies.rb:156:in `require'
    /private/tmp/demo/vendor/rails/railties/lib/commands/server.rb:82
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
    script/server:3
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So one workaround I have available to me is to drop the Sass
configuration from my &quot;config/environments/development.rb&quot; file,
and instead put it in an initializer in &quot;config/initializers&quot;
inside a conditional &quot;if ENV['RAILS_ENV'] == 'development'&quot;
block.&lt;/p&gt;
&lt;p&gt;But I think a more robust fix might be to make the changes I
suggested in my last comment. Like I said, if someone thinks this
is a good idea, please let me know and I'll prepare a patch.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-02-16T10:35:03+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>new</state>
      <tag>2.3.0</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-16T10:35:05+00:00</updated-at>
      <user-id type="integer">12845</user-id>
      <user-name>Wincent Colaiuta</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>(from [460269dcafd6d190d51176b2b03e65f3f44669b8]) Autoload ActionController::Caching::Sweeper constant [#1977 state:resolved]
http://github.com/rails/rails/commit/460269dcafd6d190d51176b2b03e65f3f44669b8</body>
      <body-html>&lt;div&gt;&lt;p&gt;(from [460269dcafd6d190d51176b2b03e65f3f44669b8]) Autoload
ActionController::Caching::Sweeper constant [&lt;a href=&quot;/projects/8994/tickets/1977&quot; title=&quot;Ticket #1977&quot;&gt;#1977&lt;/a&gt;
state:resolved] &lt;a href=&quot;http://github.com/rails/rails/commit/460269dcafd6d190d51176b2b03e65f3f44669b8&quot;&gt;
http://github.com/rails/rails/co...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-02-16T20:38:23+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- 
:state: new
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.0</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-16T20:38:23+00:00</updated-at>
      <user-id type="integer">17393</user-id>
      <user-name>Repository</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I still have this issue. I think [Wincent's solution](http://rails.lighthouseapp.com/projects/8994/tickets/1977-actioncontrollercachingsweeper-autoloading-is-broken#ticket-1977-5) should solve this.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I still have this issue. I think &lt;a href=&quot;http://rails.lighthouseapp.com/projects/8994/tickets/1977-actioncontrollercachingsweeper-autoloading-is-broken#ticket-1977-5&quot;&gt;
Wincent's solution&lt;/a&gt; should solve this.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-02-26T15:14:18+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.0</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-26T15:14:20+00:00</updated-at>
      <user-id type="integer">42312</user-id>
      <user-name>LacKac</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Yes, it would. But...

...So the bug is that since the changes were made to Rails' class caching, and since switching to using &quot;autoload&quot; pervasively, Rails has become a lot more sensitive to certain load-ordering issues.

And it's true that my suggested fix would address this one particular case.

But having said all that, I realized that the way to fix my problem was to move my Sass stuff out of environments/development.rb and into an initializer in config/initializers.

@@@
if ENV['RAILS_ENV'] == 'development'
  Sass::Plugin.options[:always_update] = true
  Sass::Plugin.options[:always_check] = true
end
@@@

You could argue that it's a bug that Rails has become less tolerant about where it accepts this kind of thing, but I think more than anything it's a documentation bug.

Turns out that this is only the last of several issues that I've run into at startup time since these changes were made to Rails. I've come to the conclusion that pretty much the _only_ thing it is safe to use inside config/environment.rb and config/environments/*.rb are &quot;config.*&quot; statements. Pretty much everything else needs to go in an initializer to avoid this kind of problem.

About the only thing that would have helped me avoid these issues would have been a big warning in the release notes, or a comment in the actual environment files advising that pretty much the only thing that should go in them should be &quot;config.*&quot; statements. I probably only ran into the issue because I was updating an app that was started with a significantly older version of Rails.

It is a bit of a step backwards that you have to put this kind of stuff inside an &quot;if&quot; that explicitly checks RAILS_ENV rather than just sticking it in config/environments/development.rb like you used to. But I doubt anyone is going to be willing to do the work to make all that work again.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Yes, it would. But...&lt;/p&gt;
&lt;p&gt;...So the bug is that since the changes were made to Rails'
class caching, and since switching to using &quot;autoload&quot; pervasively,
Rails has become a lot more sensitive to certain load-ordering
issues.&lt;/p&gt;
&lt;p&gt;And it's true that my suggested fix would address this one
particular case.&lt;/p&gt;
&lt;p&gt;But having said all that, I realized that the way to fix my
problem was to move my Sass stuff out of
environments/development.rb and into an initializer in
config/initializers.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
if ENV['RAILS_ENV'] == 'development'
  Sass::Plugin.options[:always_update] = true
  Sass::Plugin.options[:always_check] = true
end
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You could argue that it's a bug that Rails has become less
tolerant about where it accepts this kind of thing, but I think
more than anything it's a documentation bug.&lt;/p&gt;
&lt;p&gt;Turns out that this is only the last of several issues that I've
run into at startup time since these changes were made to Rails.
I've come to the conclusion that pretty much the &lt;em&gt;only&lt;/em&gt;
thing it is safe to use inside config/environment.rb and
config/environments/&lt;em&gt;.rb are &quot;config.&lt;/em&gt;&quot; statements. Pretty
much everything else needs to go in an initializer to avoid this
kind of problem.&lt;/p&gt;
&lt;p&gt;About the only thing that would have helped me avoid these
issues would have been a big warning in the release notes, or a
comment in the actual environment files advising that pretty much
the only thing that should go in them should be &quot;config.*&quot;
statements. I probably only ran into the issue because I was
updating an app that was started with a significantly older version
of Rails.&lt;/p&gt;
&lt;p&gt;It is a bit of a step backwards that you have to put this kind
of stuff inside an &quot;if&quot; that explicitly checks RAILS_ENV rather
than just sticking it in config/environments/development.rb like
you used to. But I doubt anyone is going to be willing to do the
work to make all that work again.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-02-26T19:45:59+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.0</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-02-26T19:46:03+00:00</updated-at>
      <user-id type="integer">12845</user-id>
      <user-name>Wincent Colaiuta</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I'm still seeing and error with RC2.

@@@ ruby
=&gt; Rails 2.3.1 application starting on http://0.0.0.0:3000
/Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActionController::Caching::Sweeper (NameError)
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
	from /Users/chris/workspace/petflight/app/sweepers/definition_sweeper.rb:1
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require'
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:265:in `require_or_load'
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:425:in `load_missing_constant'
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
	 ... 26 levels...
	from /Users/chris/workspace/petflight/vendor/rails/railties/lib/commands/server.rb:84
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./script/server:3
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm still seeing and error with RC2.&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
=&amp;gt; Rails 2.3.1 application starting on http://0.0.0.0:3000
/Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActionController::Caching::Sweeper (NameError)
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
	from /Users/chris/workspace/petflight/app/sweepers/definition_sweeper.rb:1
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:158:in `require'
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:265:in `require_or_load'
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:425:in `load_missing_constant'
	from /Users/chris/workspace/petflight/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
	 ... 26 levels...
	from /Users/chris/workspace/petflight/vendor/rails/railties/lib/commands/server.rb:84
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./script/server:3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-14T00:33:14+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.0</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-14T00:33:19+00:00</updated-at>
      <user-id type="integer">50638</user-id>
      <user-name>Chris Nichols</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>i'm still seeing and error wirh 2.3.2.

/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActionController::Caching::Sweeper (NameError)
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
	from ./spec/../lib/user_stamp.rb:29
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
	from ./spec/spec_helper.rb:14
	from ./spec/user_stamp_class_methods_spec.rb:1:in `require'
	from ./spec/user_stamp_class_methods_spec.rb:1
	from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/example_group_runner.rb:15:in `load'
	from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/example_group_runner.rb:15:in `load_files'
	from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/example_group_runner.rb:14:in `each'
	from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/example_group_runner.rb:14:in `load_files'
	from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/options.rb:87:in `run_examples'
	from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/command_line.rb:9:in `run'
	from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/bin/spec:4
rake aborted!
Command /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -I&quot;/Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib&quot;  &quot;/Library/Ruby/Gems/1.8/gems/rspec-1.2.0/bin/spec&quot; &quot;spec/user_stamp_class_methods_spec.rb&quot; &quot;spec/user_stamp_spec.rb&quot; &quot;spec/user_stamp_sweeper_spec.rb&quot; --colour --format progress --loadby mtime --reverse failed

(See full trace by running task with --trace)</body>
      <body-html>&lt;div&gt;&lt;p&gt;i'm still seeing and error wirh 2.3.2.&lt;/p&gt;
&lt;p&gt;
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:440:in
&lt;code&gt;load_missing_constant': uninitialized constant
ActionController::Caching::Sweeper (NameError)&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:80:in `const_missing'
from ./spec/../lib/user_stamp.rb:29
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
from ./spec/spec_helper.rb:14
from ./spec/user_stamp_class_methods_spec.rb:1:in `require'
from ./spec/user_stamp_class_methods_spec.rb:1
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/example_group_runner.rb:15:in `load'
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/example_group_runner.rb:15:in `load_files'
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/example_group_runner.rb:14:in `each'
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/example_group_runner.rb:14:in `load_files'
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/options.rb:87:in `run_examples'
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib/spec/runner/command_line.rb:9:in `run'
from /Library/Ruby/Gems/1.8/gems/rspec-1.2.0/bin/spec:4
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;rake aborted! Command
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
-I&quot;/Library/Ruby/Gems/1.8/gems/rspec-1.2.0/lib&quot;
&quot;/Library/Ruby/Gems/1.8/gems/rspec-1.2.0/bin/spec&quot;
&quot;spec/user_stamp_class_methods_spec.rb&quot; &quot;spec/user_stamp_spec.rb&quot;
&quot;spec/user_stamp_sweeper_spec.rb&quot; --colour --format progress
--loadby mtime --reverse failed&lt;/p&gt;
&lt;p&gt;(See full trace by running task with --trace)&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-16T15:04:27+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: 2.3.0
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-16T15:04:33+00:00</updated-at>
      <user-id type="integer">19461</user-id>
      <user-name>Kivanio Barbosa</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I'm getting this error as well when using Rails 2.3.2

Here are some more specifics:

if I put this line:

&lt;code&gt;
ActionController::Base.cache_store = :file_store, &quot;#{RAILS_ROOT}/tmp/cache&quot; 
&lt;/code&gt;

in either development.rb or in environment.rb then I receive this error:

&lt;code&gt;
undefined method `cache_sweeper' for Admin::BoardroomsController:Class
&lt;/code&gt;

However, if I put the cache_store command in an initializer then everything seems to work just fine.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm getting this error as well when using Rails 2.3.2&lt;/p&gt;
&lt;p&gt;Here are some more specifics:&lt;/p&gt;
&lt;p&gt;if I put this line:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;ActionController::Base.cache_store = :file_store,
&quot;#{RAILS_ROOT}/tmp/cache&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;in either development.rb or in environment.rb then I receive
this error:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;undefined method&lt;/code&gt; cache_sweeper' for
Admin::BoardroomsController:Class &amp;lt;/code&amp;gt;&lt;/p&gt;
&lt;p&gt;However, if I put the cache_store command in an initializer then
everything seems to work just fine.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-16T20:45:56+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-16T20:46:00+00:00</updated-at>
      <user-id type="integer">37336</user-id>
      <user-name>francois</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Having this issue as well, can we get this ticket reopened? Should we start a new one?</body>
      <body-html>&lt;div&gt;&lt;p&gt;Having this issue as well, can we get this ticket reopened?
Should we start a new one?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-17T20:42:01+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-17T20:42:04+00:00</updated-at>
      <user-id type="integer">42199</user-id>
      <user-name>Ben Reubenstein</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I had this problem too.  A workaround (for the time-being) is to force ActiveRecord to load first in the config.  I added a line with ActiveRecord::Base to development/production/test.rb.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I had this problem too. A workaround (for the time-being) is to
force ActiveRecord to load first in the config. I added a line with
ActiveRecord::Base to development/production/test.rb.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-18T02:21:18+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-18T02:21:22+00:00</updated-at>
      <user-id type="integer">20082</user-id>
      <user-name>Brad Folkens</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>rails 2.3.2 has the same problem.</body>
      <body-html>&lt;div&gt;&lt;p&gt;rails 2.3.2 has the same problem.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-18T08:18:05+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-18T08:18:10+00:00</updated-at>
      <user-id type="integer">28273</user-id>
      <user-name>Gudata</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I have this problem in 2.3.2, as well. I haven't troubleshot what's causing it, but adding &quot;ActiveRecord::Base&quot; as the first line of my environment config files does fix it.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I have this problem in 2.3.2, as well. I haven't troubleshot
what's causing it, but adding &quot;ActiveRecord::Base&quot; as the first
line of my environment config files does fix it.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-18T19:44:54+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-18T19:44:59+00:00</updated-at>
      <user-id type="integer">19184</user-id>
      <user-name>Chris Heald</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>If you get this error maybe you are upgrading your app from an older rails version and you should check whats triggering the loading of AR in your environment.rb earlier.

In my case it was lines:
@@@ ruby
ActionController::Base.logger = Logger.new(STDOUT)
ActionController::Base.logger.level = Logger::INFO
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.logger.level = Logger::INFO
@@@

After commenting them everthing was ok. 

Very big thanks to W. Colaiuta for defining the problem.

He also has proposed **another** fix of this issue that will work better with most of the existing rails apps</body>
      <body-html>&lt;div&gt;&lt;p&gt;If you get this error maybe you are upgrading your app from an
older rails version and you should check whats triggering the
loading of AR in your environment.rb earlier.&lt;/p&gt;
&lt;p&gt;In my case it was lines:&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
ActionController::Base.logger = Logger.new(STDOUT)
ActionController::Base.logger.level = Logger::INFO
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.logger.level = Logger::INFO
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After commenting them everthing was ok.&lt;/p&gt;
&lt;p&gt;Very big thanks to W. Colaiuta for defining the problem.&lt;/p&gt;
&lt;p&gt;He also has proposed &lt;strong&gt;another&lt;/strong&gt; fix of this issue
that will work better with most of the existing rails apps&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-19T11:34:41+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-19T11:34:46+00:00</updated-at>
      <user-id type="integer">28273</user-id>
      <user-name>Gudata</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>For me it was:

ActionController::Base.session_options[:domain] = ...</body>
      <body-html>&lt;div&gt;&lt;p&gt;For me it was:&lt;/p&gt;
&lt;p&gt;ActionController::Base.session_options[:domain] = ...&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-19T14:17:22+00:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-19T14:17:27+00:00</updated-at>
      <user-id type="integer">20082</user-id>
      <user-name>Brad Folkens</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Despite all these tweaks, I still had the problem after upgrading from 2.2.2 to 2.3.2

In config/environnements/development.rb, I had
@@@ ruby
ActionController::Base.cache_store = :file_store, &quot;#{RAILS_ROOT}/tmp/cache&quot;
@@@

After reading the &quot;Rails Guides&quot;:http://guides.rubyonrails.org/caching_with_rails.html#cache-stores, I found that I could/should write
@@@ ruby
config.cache_store = :file_store, &quot;#{RAILS_ROOT}/tmp/cache&quot;
@@@

And it worked !

In my case I found the culprit to be the cache_store definition, but I think the problem is more about calling ActionController directly and not the cache_store call itself.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Despite all these tweaks, I still had the problem after
upgrading from 2.2.2 to 2.3.2&lt;/p&gt;
&lt;p&gt;In config/environnements/development.rb, I had&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
ActionController::Base.cache_store = :file_store, &amp;quot;#{RAILS_ROOT}/tmp/cache&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After reading the &lt;a href=&quot;http://guides.rubyonrails.org/caching_with_rails.html#cache-stores&quot;&gt;
Rails Guides&lt;/a&gt;, I found that I could/should write&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
config.cache_store = :file_store, &amp;quot;#{RAILS_ROOT}/tmp/cache&amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it worked !&lt;/p&gt;
&lt;p&gt;In my case I found the culprit to be the cache_store definition,
but I think the problem is more about calling ActionController
directly and not the cache_store call itself.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-03-31T09:28:20+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-03-31T09:28:24+01:00</updated-at>
      <user-id type="integer">52463</user-id>
      <user-name>J&#233;r&#233;my Lecour</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I'm sorry, but I'm still having the issue, and don't understand how to solve it. I'm migrating a rails 2.2.3 app to 2.3.2, and since my subdomain cookie don't work any more, I've changed :

    ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:domain =&gt; &quot;.mydomain.com&quot;)

to

    ActionController::Base.session_options[:domain] = &quot;.mydomain.com&quot;

Now I get this famous `uninitialized constant ActionController::Caching::Sweeper` error. I've tried some of the tips in this ticket without success anyway :(

Thx</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm sorry, but I'm still having the issue, and don't understand
how to solve it. I'm migrating a rails 2.2.3 app to 2.3.2, and
since my subdomain cookie don't work any more, I've changed :&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:domain =&amp;gt; &quot;.mydomain.com&quot;)
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;ActionController::Base.session_options[:domain] = &quot;.mydomain.com&quot;
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;Now I get this famous &lt;code&gt;uninitialized constant
ActionController::Caching::Sweeper&lt;/code&gt; error. I've tried some of
the tips in this ticket without success anyway :(&lt;/p&gt;
&lt;p&gt;Thx&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-10T14:20:09+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-10T14:20:13+01:00</updated-at>
      <user-id type="integer">19160</user-id>
      <user-name>Gravis</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>You can add these lines to your production.rb, development.rb ....
-------------------------------
# this is a workaround for problems with loading caching sweepers
ActiveRecord::Base
-------------------------------

So you should just load AR:B first.</body>
      <body-html>&lt;div&gt;&lt;h2&gt;You can add these lines to your production.rb, development.rb
....&lt;/h2&gt;
&lt;h1&gt;this is a workaround for problems with loading caching
sweepers&lt;/h1&gt;
&lt;h2&gt;ActiveRecord::Base&lt;/h2&gt;
&lt;p&gt;So you should just load AR:B first.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-10T14:25:04+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-10T14:25:08+01:00</updated-at>
      <user-id type="integer">18890</user-id>
      <user-name>stanislav</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Update : I've corrected the issue by using :

@@@ ruby
Rails.configuration.action_controller.session[:domain] = '.staging.mydomain.net'
@@@

in my `config/environments/staging.rb` file.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Update : I've corrected the issue by using :&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
Rails.configuration.action_controller.session[:domain] = '.staging.mydomain.net'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;in my &lt;code&gt;config/environments/staging.rb&lt;/code&gt; file.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-10T14:26:29+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-10T14:26:34+01:00</updated-at>
      <user-id type="integer">19160</user-id>
      <user-name>Gravis</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Ups, a strange formatting.....

The workaround is just to add this line:
ActiveRecord::Base
In the begging of your production.rb, development.rb ....</body>
      <body-html>&lt;div&gt;&lt;p&gt;Ups, a strange formatting.....&lt;/p&gt;
&lt;p&gt;The workaround is just to add this line: ActiveRecord::Base In
the begging of your production.rb, development.rb ....&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-10T14:27:03+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-10T14:27:06+01:00</updated-at>
      <user-id type="integer">18890</user-id>
      <user-name>stanislav</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>@stanislav : thx, what do you mean by adding these line ?

just 
    ActiveRecord::Base

? I get a `NameError: uninitialized constant ActiveRecord` error when doing this, I guess I'm doing something wrong :(</body>
      <body-html>&lt;div&gt;&lt;p&gt;@stanislav : thx, what do you mean by adding these line ?&lt;/p&gt;
&lt;p&gt;just&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;ActiveRecord::Base
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;? I get a &lt;code&gt;NameError: uninitialized constant
ActiveRecord&lt;/code&gt; error when doing this, I guess I'm doing
something wrong :(&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-10T14:32:11+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-10T14:32:13+01:00</updated-at>
      <user-id type="integer">19160</user-id>
      <user-name>Gravis</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Still having this issue when working with Rails 2.3.2.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Still having this issue when working with Rails 2.3.2.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-11T23:01:24+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-11T23:01:29+01:00</updated-at>
      <user-id type="integer">49004</user-id>
      <user-name>Ozgun Ataman</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Even after removing all reference so ActionController direclty within the environment initializers, the sweepers are still not working.

* Application loads successfully
* Caching works as expected
* Sweeper ActiveRecord observers don't seem to be properly hooked into callbacks, as their methods do not get called.

This is when using Rails 2.3.2</body>
      <body-html>&lt;div&gt;&lt;p&gt;Even after removing all reference so ActionController direclty
within the environment initializers, the sweepers are still not
working.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Application loads successfully&lt;/li&gt;
&lt;li&gt;Caching works as expected&lt;/li&gt;
&lt;li&gt;Sweeper ActiveRecord observers don't seem to be properly hooked
into callbacks, as their methods do not get called.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is when using Rails 2.3.2&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-04-11T23:48:29+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-11T23:48:33+01:00</updated-at>
      <user-id type="integer">49004</user-id>
      <user-name>Ozgun Ataman</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>I see this too, wincent, can you please provide a patch along the lines you indicated.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I see this too, wincent, can you please provide a patch along
the lines you indicated.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-04-22T00:38:27+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- 
:state: resolved
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag>2.3.2</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-22T00:38:31+01:00</updated-at>
      <user-id type="integer">141</user-id>
      <user-name>Michael Koziarski</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">1</attachments-count>
      <body>Ok, here's a patch against the 2-3-stable branch. The test suite passes but I haven't been able to actually test this out on a sample app because I don't know how to run the &quot;rails&quot; command or install gems from the branch... So perhaps someone who knows how to do that can try it out.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Ok, here's a patch against the 2-3-stable branch. The test suite
passes but I haven't been able to actually test this out on a
sample app because I don't know how to run the &quot;rails&quot; command or
install gems from the branch... So perhaps someone who knows how to
do that can try it out.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">false</closed>
      <created-at type="datetime">2009-04-22T10:34:42+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- 
:tag: 2.3.2
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>open</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-04-22T10:34:46+01:00</updated-at>
      <user-id type="integer">12845</user-id>
      <user-name>Wincent Colaiuta</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>(from [5ac05f15c6d8f496c4e152dbbecd8ccb12041770]) Extract ActionController::Caching::Sweeper into separate file [#1977 state:resolved]

Signed-off-by: Joshua Peek &lt;josh@joshpeek.com&gt;
http://github.com/rails/rails/commit/5ac05f15c6d8f496c4e152dbbecd8ccb12041770</body>
      <body-html>&lt;div&gt;&lt;p&gt;(from [5ac05f15c6d8f496c4e152dbbecd8ccb12041770]) Extract
ActionController::Caching::Sweeper into separate file [&lt;a href=&quot;/projects/8994/tickets/1977&quot; title=&quot;Ticket #1977&quot;&gt;#1977&lt;/a&gt;
state:resolved]&lt;/p&gt;
&lt;p&gt;Signed-off-by: Joshua Peek &lt;a href=&quot;mailto:josh@joshpeek.com&quot;&gt;josh@joshpeek.com&lt;/a&gt; &lt;a href=&quot;http://github.com/rails/rails/commit/5ac05f15c6d8f496c4e152dbbecd8ccb12041770&quot;&gt;
http://github.com/rails/rails/co...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-05-05T02:18:13+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- 
:state: open
</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-05-05T02:18:14+01:00</updated-at>
      <user-id type="integer">17393</user-id>
      <user-name>Repository</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>I'm running the latest 2-3-stable branch with the above patch included but I'm still seeing the issue.

@@@ ruby
/Users/Me/MyApp/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActionController::Caching::Sweeper (NameError)
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
	from /Users/Me/MyApp/Code/trunk/app/sweepers/bank_sweeper.rb:1
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in `load_file'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:379:in `load_file'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:259:in `require_or_load'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:425:in `load_missing_constant'
	 ... 38 levels...
	from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
@@@</body>
      <body-html>&lt;div&gt;&lt;p&gt;I'm running the latest 2-3-stable branch with the above patch
included but I'm still seeing the issue.&lt;/p&gt;


&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;
/Users/Me/MyApp/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:440:in `load_missing_constant': uninitialized constant ActionController::Caching::Sweeper (NameError)
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
	from /Users/Me/MyApp/Code/trunk/app/sweepers/bank_sweeper.rb:1
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in `load_without_new_constant_marking'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:380:in `load_file'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in `new_constants_in'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:379:in `load_file'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:259:in `require_or_load'
	from /Users/Me/MyApp/Code/trunk/vendor/rails/activesupport/lib/active_support/dependencies.rb:425:in `load_missing_constant'
	 ... 38 levels...
	from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-05-08T14:22:54+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-05-08T14:23:00+01:00</updated-at>
      <user-id type="integer">18493</user-id>
      <user-name>Olly Headey</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Ditto on this error with the most recent 2.3 -- I was not having the issue before, and it seems the most recent commit actually caused it.

Also, action_controller/caching/sweeper.rb has a syntax error -- it's missing an &quot;end&quot;. No kidding --

http://github.com/rails/rails/blob/5ac05f15c6d8f496c4e152dbbecd8ccb12041770/actionpack/lib/action_controller/caching/sweeper.rb</body>
      <body-html>&lt;div&gt;&lt;p&gt;Ditto on this error with the most recent 2.3 -- I was not having
the issue before, and it seems the most recent commit actually
caused it.&lt;/p&gt;
&lt;p&gt;Also, action_controller/caching/sweeper.rb has a syntax error --
it's missing an &quot;end&quot;. No kidding --&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://github.com/rails/rails/blob/5ac05f15c6d8f496c4e152dbbecd8ccb12041770/actionpack/lib/action_controller/caching/sweeper.rb&quot;&gt;
http://github.com/rails/rails/bl...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-05-09T22:32:51+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-05-09T22:32:54+01:00</updated-at>
      <user-id type="integer">22427</user-id>
      <user-name>David Reese</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>I can confirm that the patch does not fix the bug on 2.3.2 and no workaround mentioned in this discussion works for me.

Can someone please reopen this ticket. This is very frustrating.</body>
      <body-html>&lt;div&gt;&lt;p&gt;I can confirm that the patch does not fix the bug on 2.3.2 and
no workaround mentioned in this discussion works for me.&lt;/p&gt;
&lt;p&gt;Can someone please reopen this ticket. This is very
frustrating.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-06-01T18:23:45+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-06-01T18:23:49+01:00</updated-at>
      <user-id type="integer">11310</user-id>
      <user-name>Andreas Korth</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Andreas,

This is fixed in 2-3-stable isn't it?</body>
      <body-html>&lt;div&gt;&lt;p&gt;Andreas,&lt;/p&gt;
&lt;p&gt;This is fixed in 2-3-stable isn't it?&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-06-01T22:05:04+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-06-01T22:05:06+01:00</updated-at>
      <user-id type="integer">141</user-id>
      <user-name>Michael Koziarski</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Just thought I'd point out that it's working for me now</body>
      <body-html>&lt;div&gt;&lt;p&gt;Just thought I'd point out that it's working for me now&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-06-01T22:16:33+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-06-01T22:16:37+01:00</updated-at>
      <user-id type="integer">18493</user-id>
      <user-name>Olly Headey</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Michael,

I'm still having this issue in Rails 2.3.2. It might be worth noting that the sweeper class is inside a plugin. Some of the reports indicate that the bug depends on the (auto)load order of classes.

The NameError does not occur if I explicitely require the file that defines ActionController::Caching::Sweeper in an initializer, like so:

require &quot;#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb&quot;

What baffles me is that there is no sweeper.rb file in actionpack-2.3.2/lib/action_controller/caching/. I thought the patch involved moving ActionController::Caching::Sweeper into a separate file.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Michael,&lt;/p&gt;
&lt;p&gt;I'm still having this issue in Rails 2.3.2. It might be worth
noting that the sweeper class is inside a plugin. Some of the
reports indicate that the bug depends on the (auto)load order of
classes.&lt;/p&gt;
&lt;p&gt;The NameError does not occur if I explicitely require the file
that defines ActionController::Caching::Sweeper in an initializer,
like so:&lt;/p&gt;
&lt;p&gt;require
&quot;#{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb&quot;&lt;/p&gt;
&lt;p&gt;What baffles me is that there is no sweeper.rb file in
actionpack-2.3.2/lib/action_controller/caching/. I thought the
patch involved moving ActionController::Caching::Sweeper into a
separate file.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-06-01T22:29:34+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-06-01T22:29:39+01:00</updated-at>
      <user-id type="integer">11310</user-id>
      <user-name>Andreas Korth</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Andreas,

We're aware of the problem in 2.3.2, however I'm pretty sure it's
fixed in 2-3-stable (a branch in git).  If you're able to confirm
that, then I'll know we're good to go and we can release 2.3.3 in a
few days which will include this fix.</body>
      <body-html>&lt;div&gt;&lt;p&gt;Andreas,&lt;/p&gt;
&lt;p&gt;We're aware of the problem in 2.3.2, however I'm pretty sure
it's&lt;br&gt;
fixed in 2-3-stable (a branch in git). If you're able to
confirm&lt;br&gt;
that, then I'll know we're good to go and we can release 2.3.3 in
a&lt;br&gt;
few days which will include this fix.&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-06-01T22:31:36+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-06-01T22:31:38+01:00</updated-at>
      <user-id type="integer">141</user-id>
      <user-name>Michael Koziarski</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
    <version type="Ticket::Version">
      <assigned-user-id type="integer">424</assigned-user-id>
      <attachments-count type="integer">2</attachments-count>
      <body>Michael,

I'm sorry there was a misunderstanding. I thought the bug was fixed in 2.3.2. I tried 2-3-stable and it works fine.

Thanks for working this out with me :)

I'm looking forward to 2.3.3!</body>
      <body-html>&lt;div&gt;&lt;p&gt;Michael,&lt;/p&gt;
&lt;p&gt;I'm sorry there was a misunderstanding. I thought the bug was
fixed in 2.3.2. I tried 2-3-stable and it works fine.&lt;/p&gt;
&lt;p&gt;Thanks for working this out with me :)&lt;/p&gt;
&lt;p&gt;I'm looking forward to 2.3.3!&lt;/p&gt;&lt;/div&gt;</body-html>
      <closed type="boolean">true</closed>
      <created-at type="datetime">2009-06-01T22:44:49+01:00</created-at>
      <creator-id type="integer">12845</creator-id>
      <diffable-attributes type="yaml">--- {}

</diffable-attributes>
      <milestone-id type="integer">9903</milestone-id>
      <number type="integer">1977</number>
      <permalink>actioncontrollercachingsweeper-autoloading-is-broken</permalink>
      <priority type="integer">0</priority>
      <project-id type="integer">8994</project-id>
      <state>resolved</state>
      <tag>2.3.2 patch</tag>
      <title>ActionController::Caching::Sweeper autoloading is broken</title>
      <updated-at type="datetime">2009-06-01T22:44:55+01:00</updated-at>
      <user-id type="integer">11310</user-id>
      <user-name>Andreas Korth</user-name>
      <creator-name>Wincent Colaiuta</creator-name>
      <assigned-user-name>Joshua Peek</assigned-user-name>
      <url>http://rails.lighthouseapp.com/projects/8994/tickets/1977</url>
      <milestone-title>2.x</milestone-title>
    </version>
  </versions>
  <attachments type="array">
    <attachment type="Attachment">
      <code>4db9372d3873cb4d9699747302df05fa865a2909</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-02-15T18:53:37+00:00</created-at>
      <filename>0001-Fix-autoloading-of-ActionController-Caching-Sweepe.patch</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">88998</id>
      <size type="integer">1412</size>
      <uploader-id type="integer">12845</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/88998/0001-Fix-autoloading-of-ActionController-Caching-Sweepe.patch</url>
    </attachment>
    <attachment type="Attachment">
      <code>797ccc5b5b898789e4d6cf33265b7cef7c20b5e9</code>
      <content-type>text/plain</content-type>
      <created-at type="datetime">2009-04-22T10:34:42+01:00</created-at>
      <filename>0001-Extract-ActionController-Caching-Sweeper-into-sepa.patch</filename>
      <height type="integer" nil="true"></height>
      <id type="integer">113880</id>
      <size type="integer">5175</size>
      <uploader-id type="integer">12845</uploader-id>
      <width type="integer" nil="true"></width>
      <url>http://rails.lighthouseapp.com/attachments/113880/0001-Extract-ActionController-Caching-Sweeper-into-sepa.patch</url>
    </attachment>
  </attachments>
</ticket>
