[Catalyst] Catalyst actions
Matt S Trout
dbix-class at trout.me.uk
Thu May 17 22:33:36 GMT 2007
On Thu, May 17, 2007 at 04:38:41PM +0100, Richard Jones wrote:
> Help - I'm going round in circles with Catalyst actions. I want
> http://localhost:3000/search to map to the method search() in
> MyApp::Controller::Search, so I defined the method as:
>
> sub search : Path Form('/search') { # a formbuilder method
> if ( $form->submitted && $form->validate ) {
> $c->detach('retrieve');
> }
> # etc;
> }
Which has a -public- -URI- of '/search' but the action has a Catalyst
"private path" of '/search/search'
> Couldn't render template "file error - search/search: not found"
And as documented, View::TT uses the private path to determine the default
template.
$c->stash(template => 'search');
would override that.
> I also sometime see [% Catalyst.uri_for('search') %] translating to
> 'base_url/search/search' in the template, and though ugly, it does work.
That's cuz it generates a URI relative to the current namespace. I'd generally
avoid passing strings to uri_for except for static files, and instead pass
$controller->action_for($name_of_action_method).
> I've also tried playing with calling the default method 'index' and
> 'default', and various attributes Local, Path, Global (I know that one's
> wrong) but ran into problems with all of those. I can't do a
> $c->res->redirect to the url '/search' as I need the original search
> params reloading. Can anyone see an obvious solution to this? Probably
> to do it the correct way!
$c->uri_for($self->action_for('search'), $c->req->query_parameters); ?
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
More information about the Catalyst
mailing list