Hi there!
I have done the following:
-
added the following in config/enivronment.rb:
config.load_paths += %W( #{RAILS_ROOT}/app/cachers ) -
in app/cachers I created profile_sweeper.rb:
class ProfileSweeper < ActionController::Caching::Sweeper
observe User
def after_save(record)
breakpoint
… do something …
end
def after_update(record)
breakpoint
end
end
- In my app/controllers/user_controller.rb I added the following:
class UserController < ApplicationController
cache_sweeper :profile_sweeper, :only=>[:edit]
…
However when I called the page /user/edit and saved my changes to the
database by a @user.save, the cache sweeper was never invoked…
Do anyone know what’s wrong with my code? I am wondering for a coupple
of hours and could not find any solution while Rails didn’t inform me
any error…
Thank for you kind attention!
Regards,
Vance