-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Undefined method `cache_sweeper' or uninitialized constant ActionController::Caching::Sweeper #4
Comments
Is |
Yes, sure. All other controllers, models work as expected |
The only reason that this is not working is that |
I will try to create a minimalistic app to reproduce. |
This will help a lot. thank you |
https://github.com/khustochka/cache_sweeper_fail If you run The underlying problem is undefined method `cache_sweeper'. If you start the server and go to http://127.0.0.1:3000/posts you'll see this error. |
still having this issue, even with rails head you can try my fork of @khustochka example (changed it from pg to sqlite) cd /tmp
git clone https://github.com/rmoriz/cache_sweeper_fail.git
cd cache_sweeper_fail
bundle
RAILS_ENV=production bundle exec rake db:setup
#rake aborted!
#undefined method `cache_sweeper' for PostsController:Class
#/private/tmp/cache_sweeper_fail/app/controllers/posts_controller.rb:4:in `<class:PostsController>'
#/private/tmp/cache_sweeper_fail/app/controllers/posts_controller.rb:1:in `<top (required)>'
#/private/tmp/cache_sweeper_fail/config/environment.rb:5:in `<top (required)>'
#Tasks: TOP => db:setup => db:schema:load_if_ruby => environment
#(See full trace by running task with --trace)
#RAILS_ENV=production bundle exec rake db:setup 4,48s user 0,37s system 99% cpu 4,886 total |
soaring in the issue rails/rails#10294 was able to dig deeper
|
As for my investigation there is also an Autoload issue. I debugged it in production env. When it reaches this line As a workaround I just manually require 'rails/observers/activerecord/observer' in my application.rb |
Borrowed from melindaweathers's commit(couldn't find that one on her fork) rails@e2fba81
The hack from @melindaweathers works fine. Using the fork of @kinopyo for now. |
Alternatively you can add
into your |
I ran into
Any ideas? I feel like the answer lies in the railtie-- maybe removing |
Closed with #8 |
Like @Xuhao, I am also still getting problems in 0.1.2 (uninitialized constant ActionController::Caching::Sweeper). Fixed for now by blindly adding |
Me too |
Unfortunately it is not working: rails/rails-observers#4
I am also facing this issue with rails 4 any solution? |
I'm getting "uninitialized constant ParentSweeper". any resolution yet? |
This error has to be fixed via #24 |
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 |
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.0.0 supports Rails 4, but it's not available in the rubygems.org, so had to specify github repo and the alpha1 version. gem 'friendly_id', '5.0.0.alpha1', github: 'FriendlyId/friendly_id' The error of friendly_id may look like this: > NoMethodError - undefined method `synchronize' for nil:NilClass: * carrierwave Had to make some changes manually for my PhotoUploader which inheritents CarrierWave::Uploader::Base. class PhotoUploader < CarrierWave::Uploader::Base # include Sprockets::Helpers::RailsHelper # include Sprockets::Helpers::IsolatedHelper include Sprockets::Rails::Helper end Was just copied from the commit: carrierwaveuploader/carrierwave#661 carrierwaveuploader/carrierwave@c097370 * rails-observers The error was like this: Undefined method `cache_sweeper' or uninitialized constant ActionController::Caching::Sweeper Was issued in rails/rails-observers#4 * protected_attributes Ran into this error: uninitialized constant ActiveRecord::MassAssignmentSecurity::NestedAttributes::ClassMethods::REJECT_ALL_BLANK_PROC rails/protected_attributes#8 Had no time to try those pull requests, so just comment out for now.
I fixed the error: |
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 errorundefined 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 autoloadedI tried both v 1.1.0 and edge version of the gem.
The text was updated successfully, but these errors were encountered: