[Catalyst] Can't seem to use forward or detach. Any special requirements?

kakimoto at tpg.com.au kakimoto at tpg.com.au
Mon Apr 27 01:09:19 GMT 2009


Hello, Oliver,

 Good morning.
 Referring to
http://kobesearch.cpan.org/htdocs/Catalyst-Runtime/Catalyst.html#c_gt_detach_class_method_arguments,
under "$c->detach()",
it says that detach is the same as forward, but doesn't return to the
previous action when processing is finished. 

 Comments?

thank you

k. akimoto



Quoting oliver.g.charles at googlemail.com:

> kakimoto at tpg.com.au wrote:
> > hello, all,
> 
> >  I have a method in my controller which adds entries.
> 
> >  The method is setup to match the path of
> 'users/subscriptions/add'.
> 
> >  Upon successfully adding entries, I want the same method to be
> executed
> > again (only that the method will know which template (view) to
> call. I
> > tried using a detach (and even a forward) and I keep getting an
> error of
> > , 'Couldn't forward to command "/users/subscriptions/add": Invalid
> > action or component.'
> 
> This is because the  path you specified is not the internal path
> name to the action (that is whatever you named your controller
> /create),
> but it is the external path. Detach works on internal path names.
> 
> > Reason why I am issuing a detach - To prohibit users from pressing
> > "Refresh" on the browser which will cause the application to readd
> the
> > entry again into the database (this happens because I suspect that
> the
> > request object is not flushed. I could easily kill off the
> parameters in
> > the request object but I figured I use a detach and have another
> (view)
> > template show up.
> 
> Detach will simply cause another action to be executed before
> returning
> to the browser, so this won't solve your problem. You need to cause
> a
> redirect to solve your problem, so the correct code would be:
> 
> $c->res->redirect($c->uri_for_action('/controller/create')
> 
> Where controller is the name of the controller that contains the
> action
> you provided in your email.
> 
> Hope that helps
> 
> --
>     Oliver Charles / aCiD2
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
> 
> 
> 






More information about the Catalyst mailing list