Action caching with params

I was attempting to cache an action that had a URL like this:[]=2005&years[]=2006&bar=5&baz=blue

which returns different data than, say[]=2004&years[]=2005&bar=6&baz=red

However, the cached fragment would always be named, no matter what parameters where
passed in, which would result in incorrect data being rendered on a
cached page.

I eventually tracked the culprit to ActionController::Base#url_for,
which the fragment cacher calls well reading and writing the fragment.
In my controller, I added this:

def url_for(options = nil, *parameters_for_method_reference)
super( options ? options : params, parameters_for_method_reference)

which sends the params hash as options, if no options are specified
(as is the case with the cacher).

So is this a bug in rails or a misunderstanding on my part as to the
proper behavior? Am I doing something dangerous here by fiddling with
one of the more used methods?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs