I’m working on a program which relies on heavy cache sweeper usage.
I’ve just bumped onto an odd problem. When using render_component
method in layouts or templates with cache sweeping turned on, Rails
throws an exception with the following message:
NoMethodError in TestController#index
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.controller_name
where TestController is obviously my controller class name. I’m running
Rails 1.1.6 on linux box. My test app which extracts the error consists
of a controller which body is only:
class TestController < ApplicationController
render :text => “foo”
The file sweeper.rb contains my sweeper class definition:
class Sweeper < ActionController::Caching::Sweeper
Bar is an empty model, with a table bars containing only id field.
I’ve turned the caching on by setting
config.action_controller.perform_caching = true in
Exception is thrown in
actionpack-1.12.5/lib/action_controller/caching.rb file in line 541.
Am I doing something wrong or it’s some kind of a Rails bug?