I'm trying to set up a restful route where an Album resource has a
singletone Artwork resource. Sounds simple enough:
map.resources :albums do |album|
:controller => 'artwork', :format => 'jpg'
With the above routing config, /albums/xxx/artwork.jpg works as
However, my artwork controller also has an option to resize the image
if a :size parameter is given. This also works:
However, I want to cache the resized artwork using Rails caching.
Adding caches_page :show works and the cached file is saved under
But what about when I specify a size? I want these to be cached
individually. Specifying size as a query string parameter means the
size is ignored when caching takes place (it is always stored as
artwork.jpg). What I really need is to be able to move the size
parameter into the URL, so it looks something like this:
This would mean page caching does what I want it to do. However I
cannot see any easy way of moving size into the URL using
map.resource. I can set up a custom route but any restful url helpers
take no notice of it. Can anybody help me with this?