Rails is not deleting a cache/.html page when the sweeper is called
I'm having some issues with Sweepers and Caching in Rails.
The .html file in /cache is开发者_开发问答 being generated on first view.
The Sweeper action is being called when needed.
However, the sweeper action is not deleting the .html page from /cache
The code below is stripped down from my /controllers and /sweepers directory. the puts
lines both log, so I know that we're executing fine -- the expire command just doesn't seem to delete the file.
anyone have an idea where i can lool ?
class WidgetsController < ApplicationController
cache_sweeper :widget_sweeper
caches_page :help
def help
render :template => '/widgets/help.html'
end
end
class WidgetSweeper < ActionController::Caching::Sweeper
observe HelpPage
def after_save(record)
puts "record "
puts record.inspect
expire_page(:controller => 'widgets', :action => 'help')
puts "ok!"
end
end
Are you just testing this by manipulating some HelpPage records in the console? It looks like you have to affect the changes in a controller.
I made a test app using the code you supplied above and ran it with caching enabled. I created some new HelpPage records in the rails console, and I got the two log messages but no page expiration.
However, when I created a new HelpPage in a controller, I did get the page expiration as expected.
精彩评论