[Catalyst] Minor Problem With Tutorial

Wade.Stuart at fallon.com Wade.Stuart at fallon.com
Mon Aug 14 21:14:03 CEST 2006

catalyst-bounces at lists.rawmode.org wrote on 08/14/2006 01:57:25 PM:

> On 8/14/06, Kevin Monceaux <Kevin at rawfeddogs.net> wrote:
> > Anyway, I'm at the end of the BasicCRUD section of the tutorial where
> > creates the Books::Delete method.  The last line in the method is:
> >
> >     $c->forward('list');
> >
> > Catalyst appears to be ignoring this statement.  When I tried to delete
> > book I got:
> >
> > Coldn't render template "file error - books/delete.tt2: not found"
> >
> > So, I tried creating an empty books/delete.tt2 template to see if
> > just wanted to find a template file matching the method it was in
> > performing the redirect.  It then displayed the blank page instead of
> > redirecting to the list method.  I'm sure there is something simple I
> > overlooked.
> This might seem a little bit non-intuitive when you're just a beginner
> at Catalyst, but $c->forward('list') won't cause Catalyst to render
> your books/list.tt2 template. It will execute the 'list' action and
> return, getting back to your books/delete.tt2 template.

To fill in a bit more, forward does not render list's template because

forward causes the program to execute list's action then returns to

where it left off in delete -- only to fall off to the END block

which usually passes to the view.

> In order to achieve the desired behaviour you could either issue a
> redirect response (through $c->response->redirect($uri) ) or
> explicitely set the desired template filename.

When setting the template name,  it forward sill still come back

to the action that called it,  but END will forward to the view and

deal with the template that you have set.

If you want to execute another action and not come back,  you can call

$c->detach("list") which does not continue executing at the current

action after the call.

More information about the Catalyst mailing list