[Catalyst] Trouble with Chained Actions and Redirects?

Robert 'phaylon' Sedlacek phaylon at dunkelheit.at
Tue Sep 19 12:54:51 CEST 2006


John Napiorkowski said:
> I have a controller with some chained actions.  One of
> the actions (not an endpoint) will redirect given a
> certain value for the arguments.  However I find that
> this doesn't stop the chain from completing.  I still
> get a line about the redirect in the log, but the
> endpoint in that chain still activates.
>
> I find that this doesn't happen when I use $c->detach,
> although in this circumstance detach is not the best
> use for me.

Of course, redirect and detach/foward are completely different. While
redirect may seem like "external detach," it isn't. A redirect is an
answer to the browser, telling him to look up another site. A forward or
detach moves the execution to another action. If you call redirect, it
will just set the appropriate headers. It can't just stop there, because
you might want to change those headers or do something else before the
redirect (E.g. Setting a  message in the flash).

> Has anyone run into this before and found a way around
> it?

See Ash's answer, if you want to detach, detach :) (Note that detach can
also be called without arguments at all, just ending the execution).

hth,
Robert




More information about the Catalyst mailing list