Hi experts,

I have built a typical cache sweeper class:

#======================
class PrivilegeCacheSweeper < ActionController::Caching::Sweeper
  observe User

  def after_update(user)
   expire_cache_for(user)
  end


  private

  def expire_cache_for(user)
    p "Hi there!!!"
    expire_action(:controller => "users", :action => "user_view")
  end
end
#======================

In the UsersController I set:
#======================
class UsersController < ApplicationController

  caches_action :user_view
  cache_sweeper :privilege_cache_sweeper

  def user_view
    #code to show list of accessible units of login user
  end

  def update
    #update user
  end
end
#======================

In environment.rb, I already set:
#======================
config.action_controller.perform_caching = true
#======================

The problem is that after the user is updated, the page "user_view" is
still cached when being refreshed (The output shows "Cached fragment
hit: views/localhost:3000/users/user_view").

The output also shows the text "Hi there!!!" => It means method
"expire_cache_for(user)" is called. However, "expire_action()" seems not
to work at all.

I also tested the expire_action(:controller => "users", :action =>
"user_view") by inserting it directly in UsersController::update method.
It works fine!

Could you give me any suggestion to solve this problem?

My application runs on:

Rails: 2.3.2
Ruby: 1.8
OS: Ubuntu 8.04

Thank you very much.
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to