[Catalyst] Best Practices - an application.
mnichols at mojosoft.org
mnichols at mojosoft.org
Tue Sep 19 05:46:24 CEST 2006
"Kieren Diment" <diment at gmail.com> writes:
> On 18/09/06, mnichols at mojosoft.org <mnichols at mojosoft.org> wrote:
>
> sub default : Private {
> my ( $self, $c ) = @_;
>
> # Hello World
> # $c->response->body( $c->welcome_message );
> $c->forward('View::TT');
>
> }
>
>
> Don't forward to View::TT in your default action, that's for end :
> Private, and doesn't need to be done at all if you're using
> Catalyst::Plugin::DefaultEnd or RenderView.
Thanks, I was thinking end when I did it... As it seems that Root.pm already has RenderView, I'll leave it at that.
>
> You're getting the error because you haven't set a template in your
> action.
>
> usually default is for 404 errors only - something like:
>
> sub default : Private {
> my ($self, $c) = @_;
> $c->res->status(404);
> $c->res->body('404 not found');
> # or maybe $c->stash->{template} = '404.tt'
> }
>
Is it generally good practice to not put index like pages in default and instead have an error message? I can see that being useful when your default home page shows up in an ajax call. I guess this maybe why there are now index functions.
Thanks for the comments.
mojo
More information about the Catalyst
mailing list