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 method
cache_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
- Adding hack mentioned in rails-observers issue #4 Borrowed from melindaweathers's commit(couldn't find that one on her fork) https://github.com/rails/rails-observers/commit/e2fba819ee77b683a210115e81... — committed to kinopyo/rails-observers by kinopyo 11 years ago
- Adds rails-observers gem for cache sweeping. Unfortunately it is not working: https://github.com/rails/rails-observers/issues/4 — committed to robinboening/alchemy_cms by tvdeyen 11 years ago
- Upgrade to rails 4, first step. Now at least can start the server and jump around between pages. Problems with these gems: * simple_form - update version to 3.0.0.rc * friendly_id friendly_id ~> 5... — committed to dddaisuke/quoty by kinopyo 11 years ago
I fixed the error:
uninitialized constant ActionController::Caching::Sweeper (NameError)
by addingrequire "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?