rails-observers: Undefined method `cache_sweeper' or uninitialized constant ActionController::Caching::Sweeper

I use cache sweepers in my project and try to make it work on Rails 4 master. I have added gem 'rails-observers', updated bundle. But I am still getting error undefined methodcache_sweeper’ for ObservationsController:Class (NoMethodError)`.

I tried to debug and saw that rails-observers are actually loaded, but unfortunately I failed to go deeper into that eager_autoload stuff.

If I try to require my sweeper on top of controller I got error there: uninitialized constant ActionController::Caching::Sweeper. So it seems the values are not properly autoloaded

I tried both v 1.1.0 and edge version of the gem.

About this issue

  • Original URL
  • State: open
  • Created 11 years ago
  • Comments: 22 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I fixed the error: uninitialized constant ActionController::Caching::Sweeper (NameError) by adding require "rails/observers/action_controller/caching" at the top of the sweeper file.

Using the gem from the master branch, I’m also still getting this error. Example: jb/rails-sweeper-error

As a work around, I’m using an observer instead, and expiring the cache with ApplicationController.expire_page('/index.html'). But maybe I’m missing something?