Skip to content

Instantly share code, notes, and snippets.

@rgrove
Created April 20, 2009 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgrove/98356 to your computer and use it in GitHub Desktop.
Save rgrove/98356 to your computer and use it in GitHub Desktop.
Ramaze action cache vulnerable to collisions between controllers with identical method names
require 'rubygems'
require 'ramaze'
class MainController < Ramaze::Controller
map '/'
helper :cache
def index
%[
<html>
<head><title>examples/caching</title></head>
<body>
<p>
This action just shows you a random number: #{rand * 100}.<br />
If you <a href="/">refresh</a> the page it won't change since you see a cached version.<br />
But if you <a href="/invalidate">invalidate</a> it, the page will be regenerated.
</p>
</body>
</html>
]
end
cache_action :method => :index
def invalidate
Ramaze::Cache.action.delete(:method => 'index')
redirect :/
end
end
class FooController < Ramaze::Controller
map '/foo'
helper :cache
def index
(rand * 100).to_s
end
cache_action :method => :index
end
Ramaze.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment