# Cache sweepers not working since last upgrade

**URL:** <https://www.ruby-forum.com/t/cache-sweepers-not-working-since-last-upgrade/93790>\
**Category:** Engines Development\
**Created:** [April 10, 2006, 11:42am UTC](https://www.ruby-forum.com/t/cache-sweepers-not-working-since-last-upgrade/93790 "2006-04-10T11:42:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [April 10, 2006, 11:42am UTC](https://www.ruby-forum.com/t/cache-sweepers-not-working-since-last-upgrade/93790/1 "2006-04-10T11:42:21Z")

</div>

Hi all,  
I updated Rails to 1.1.1 and engines to 1.1.1.  
Since then, my cache sweepers stopped working.  
I get this error:  
You have a nil object when you didn’t expect it!  
The error occured while evaluating nil.controller\_name

See end of post for full error trace.

When I move the controller from vendor/plugins/myengine/app/controllers  
to app/controllers, everything works fine, so I guess it’s an engine  
bug.

Controller:

class TestController \< ApplicationController

layout false  
helper :admin\_pages  
model :page\_element, :element\_sweeper  
cache\_sweeper :element\_sweeper  
def test

render :inline=\>“blaa”  
end  
end

Sweeper:

class ElementSweeper \< ActionController::Caching::Sweeper  
observe PageElement  
end

Errors:

NoMethodError (You have a nil object when you didn’t expect it!  
The error occured while evaluating nil.controller\_name):  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/caching.rb:541:in  
`callback' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/caching.rb:534:in`after’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/filters.rb:227:in  
`around_filter' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:227:in`call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/filters.rb:401:in  
`call_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:394:in`each’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/filters.rb:394:in  
`call_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:389:in`after\_action’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/filters.rb:369:in  
`perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in`perform\_action\_without\_rescue’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/benchmarking.rb:69:in  
`measure' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in`perform\_action\_without\_rescue’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/rescue.rb:82:in  
`perform_action' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in`send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/base.rb:381:in  
`process_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in`process\_without\_session\_management\_support’  
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/session\_management.rb:117:in  
`process' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in`dispatch’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick\_server.rb:115:in  
`handle_dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in`service’  
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in`run’  
/usr/lib/ruby/1.8/webrick/server.rb:155:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:144:in`start’  
/usr/lib/ruby/1.8/webrick/server.rb:144:in `start_thread' /usr/lib/ruby/1.8/webrick/server.rb:94:in`start’  
/usr/lib/ruby/1.8/webrick/server.rb:89:in `each' /usr/lib/ruby/1.8/webrick/server.rb:89:in`start’  
/usr/lib/ruby/1.8/webrick/server.rb:79:in `start' /usr/lib/ruby/1.8/webrick/server.rb:79:in`start’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick\_server.rb:67:in  
`dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59 /usr/lib/ruby/1.8/rubygems/custom_require.rb:21:in`require\_\_’  
/usr/lib/ruby/1.8/rubygems/custom\_require.rb:21:in `require' /usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in`require’  
/usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30  
/usr/lib/ruby/1.8/rubygems/custom\_require.rb:21:in `require__' /usr/lib/ruby/1.8/rubygems/custom_require.rb:21:in`require’  
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active\_support/dependencies.rb:147:in  
`require’  
script/server:3

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [April 11, 2006, 12:36am UTC](https://www.ruby-forum.com/t/cache-sweepers-not-working-since-last-upgrade/93790/2 "2006-04-11T00:36:19Z")

</div>

Yeah, I noticed this too. I think it has to do with Rails rather than  
Engines… might even be a bug. I noticed in the changelog that the  
controller instance variable inside sweepers is set to nil “between  
requests”… whatever that means. I figure that’s what’s causing the  
error, but I haven’t figured out how to fix it or even looked into  
whether its a reported bug. I just have my sweepers turned off for  
now. : (

Let me know if you learn anything about this.

On 4/10/06, Martin S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> to app/controllers, everything works fine, so I guess it’s an engine  
> model :page\_element, :element\_sweeper  
> observe PageElement  
> /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action\_controller/caching.rb:534:in  
> `call_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in `dispatch’  
> /usr/lib/ruby/1.8/webrick/server.rb:89:in `each’  
> /usr/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30
> 
> * * *
> 
> engine-developers mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org](http://lists.rails-engines.org/listinfo.cgi/engine-developers-rails-engines.org)

–  
Jeff L.  
[http://blogrium.com/](http://blogrium.com/)

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [April 11, 2006, 12:47am UTC](https://www.ruby-forum.com/t/cache-sweepers-not-working-since-last-upgrade/93790/3 "2006-04-11T00:47:14Z")

</div>

I got this with my app that doesn’t use engines at all:

You have a nil object when you didn’t expect it!  
The error occured while evaluating nil.controller\_name

I think it has to do with using external libraries, because it seems to  
be caused by this… @status\_options =  
YAML::load(Settings.status\_options)

I’m pretty sure this is related to your problem. Interestingly, things  
work normally for me when I set config.action\_controller.perform\_caching  
= false in production.rb. Does it do that for you guys too?

Simon.

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [April 11, 2006, 12:54am UTC](https://www.ruby-forum.com/t/cache-sweepers-not-working-since-last-upgrade/93790/4 "2006-04-11T00:54:35Z")

</div>

I don’t know about external libraries, but setting perform\_caching to  
false should be expected to avoid the problem… if you’re not  
performing caching, sweepers don’t need to run, which is where the  
problem is.

On 4/10/06, sclaret [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> work normally for me when I set config.action\_controller.perform\_caching

–  
Jeff L.  
[http://blogrium.com/](http://blogrium.com/)

---

<div class="post-metadata">

**Author:** ![msojka](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@msojka](https://www.ruby-forum.com/u/msojka)\
**Post date:** [April 13, 2006, 10:34pm UTC](https://www.ruby-forum.com/t/cache-sweepers-not-working-since-last-upgrade/93790/5 "2006-04-13T22:34:26Z")

</div>

Jeff L. wrote:

> I don’t know about external libraries, but setting perform\_caching to  
> false should be expected to avoid the problem… if you’re not  
> performing caching, sweepers don’t need to run, which is where the  
> problem is.
> 
> On 4/10/06, sclaret [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > work normally for me when I set config.action\_controller.perform\_caching
> 
> –  
> Jeff L.  
> [http://blogrium.com/](http://blogrium.com/)

actually the sweepers work when I call them from norman (non-engine)  
controllers, so the error must be on the engine side
