I have some code that uses caches_action to cache the output of a
“show” method, and a before_filter to redirect the user to a login
page if the user hasn’t already logged in. Unfortunately, when
redirect_to method sends the user off to the login page, caches_action
saves that redirect, so that subsequent attempts to access the same
“show” URL return a page that says “You are being redirected.”
Is there a way to stop the caching when a redirect occurs in a
before_filter?
Here’s some more detail, in case the above wasn’t clear:
-
The user attempts to go http://csb-paul:3000/form/show/PHR, and
instead gets redirected to
http://csb-paul:3000/login/login. So far, so good. -
Once that happens, every attempt to get
http://csb-paul:3000/form/show/PHR
(whether or not the user has logged in) returns a page that says “You
are being redirected.” I put a debugging statement in my
before_filter, and it is not run once the page is cached (by
caches_action, which I thought was always supposed to run the before
filters??)
Also, when #2 happens, I am getting a message in the log that says,
“Filter chain halted as […filters.rb:597>] did not yield.” I’m not
sure if that is related to the problem.
Any helpful suggestions would be appreciated. Thanks,
–Paul