Expire pages that want file, when file is successfully uploaded

Reported by Andrew Stacey
This commit is contained in:
Jacques Distler 2011-09-09 00:05:54 -05:00
parent ee05118e8f
commit c603aca852
3 changed files with 16 additions and 0 deletions

View file

@ -18,6 +18,9 @@ class FileController < ApplicationController
new_file = @web.wiki_files.create(params['file'])
if new_file.valid?
flash[:info] = "File '#{@file_name}' successfully uploaded"
WikiReference.pages_that_want_file(@web, @file_name).each do |page|
RevisionSweeper.expire_page(page)
end
redirect_to(params['referring_page'])
else
# pass the file with errors back into the form

View file

@ -25,6 +25,10 @@ class RevisionSweeper < ActionController::Caching::Sweeper
end
end
def self.expire_page(page)
new.expire_caches(page)
end
private
def expire_caches(page)