# A bug in sweeper.rb? \[was: A frustrating and strange error when config.action\_controller.perform\_ca

**URL:** <https://www.ruby-forum.com/t/a-bug-in-sweeper-rb-was-a-frustrating-and-strange-error-when-config-action-controller-perform-ca/165855>\
**Category:** Rails\
**Created:** [April 18, 2009, 12:14pm UTC](https://www.ruby-forum.com/t/a-bug-in-sweeper-rb-was-a-frustrating-and-strange-error-when-config-action-controller-perform-ca/165855 "2009-04-18T12:14:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim\_U](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90db22/32.png) [@Tim\_U](https://www.ruby-forum.com/u/Tim_U)\
**Post date:** [April 18, 2009, 12:14pm UTC](https://www.ruby-forum.com/t/a-bug-in-sweeper-rb-was-a-frustrating-and-strange-error-when-config-action-controller-perform-ca/165855/1 "2009-04-18T12:14:59Z")

</div>

I fired up the debugger and watched the code happen tonight.

The problem occurs if the config.action\_controller.perform\_caching =  
true in  
your environment. It’s not set to true in development but it is set to  
true  
in production and staging.

The problem occurs not in my controllers but in sweeping.rb (part of  
rails).  
Rails calls this code for every controller which was instantiated in the  
same request ( I think). Running the page it “sweeps” the following  
controllers in this order.

#\<MatchCommissionedScheduledController:0xb679b4fc\>  
#MatchController:0xb61694f8

The problem is that on the second call to clean up MatchController it  
pukes.  
The code snippets in sweeping.rb are…

The cleanup is in the following method of sweep.rb

def after(controller)  
callback(:after) if controller.perform\_caching  
# Clean up, so that the controller can be collected after this  
request  
self.controller = nil  
end

A little later…

def callback(timing)  
controller\_callback\_method\_name =  
“#{timing}_#{controller.controller\_name.underscore}"  
action\_callback\_method\_name =  
"#{controller\_callback\_method\_name}_#{controller.action\_name}”

```
        __send__ (controller_callback_method_name) if

```

respond\_to?(controller\_callback\_method\_name, true)  
**send** (action\_callback\_method\_name) if  
respond\_to?(action\_callback\_method\_name, true)  
end

The problem is that after the first controller has been cleared  
controller  
is nil when it gets to the callback (even if it’s not nil when it hits  
the  
after method)

I am not quite sure what is the problem but could this be a bug in  
sweeper.rb?
