Forum: Ruby on Rails [ANN] Broomstick - Making Sweeping a Little Bit easer

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Charlie B. (Guest)
on 2006-04-20 17:38
Page sweeping just got a whole lot easier! Rails only offers methods to
expire a single page but no methods to expire an entire action or
controller. This plugin does just that.

This initial release of the plugin only adds one method
(expire_each_page() ) to your disposal. Hereâ??s a quick example and
exactly how it works.

expire_each_page(:controller  =>  'pragmatic', :action  => 'view')

The above method will call url_for on the controller/action combo and
expire all pages that are under public/pragmatic/view/ and

expire_each_page(:controller  =>  'pragmatic')

The above method will call url_for on the controller and expire all
pages that are under public/pragmatic/ and public/pragmatic.html
To install this plugin just run:

script/plugin install


Make sure that this broomstick directory in under
There are a couple of issues you will need to fix in your routes.rb and
your .htaccess or lighttpd.conf if you want to use this plugin. First
let fix your routes.rb. If your routes.rb has this line:

 map.connect '', :controller => "pragmatic"

you will need to add this line directly above it:

  map.connect '/pragmatic', :controller =>  "pragmatic"
  map.connect '', :controller => "pragmatic"

By adding the new line, you are telling rails to map all calls to
url_for(:controller => â??pragmaticâ??) back to /pragmatic. Without this the
exprire_each_page method will not work for your pragmatic controller
(the controller that holds your initial action) because it is mapped
back to â??/â??. This would cause the plugin to delete your entire public
directory. Donâ??t worry, if you forgot to change this you will see a very
nice long message in your logs and no files will be removed.

The second issue is directly related to this routes.rb change. By adding
this new map.connect statement, rails will stop caching an index.html
page. It will start caching a pragmatic.html page. This works great but
a new page will be created on each call because Apache is still looking
for index.html. To fix this we modify the public/.htaccess file so that
Apache will look for the pragmatic.html file instead of index.html. Here
are the modified lines in the .htaccess file. This:

RewriteRule ^$ index.html [QSA]
 changes to this:
RewriteRule ^$ pragmatic.html [QSA]

If you are using lighttpd add this line:

  url.rewrite = (
    "^/$" => "pragmatic.html",
    "^([^.]+)$" => "$1.html" )

Thatâ??s all it takes to be able to do mass page expirations based on a
controller and or action.

Released under the same license as Ruby. No Support. No Warranty. Back
up your public directory (or whatever you have your rails cache
directory set to) before usingâ?¦I hope you already knew that!

Charlie B.
unknown (Guest)
on 2006-04-20 18:12
(Received via mailing list)
Available at :)

And yes, I'll be working on improving the format of the description.
Charlie B. (Guest)
on 2006-04-20 18:16
unknown wrote:
> Available at :)
> And yes, I'll be working on improving the format of the description.

Thanks for posting the plugin, my next step was to set it up on your
This topic is locked and can not be replied to.