[Catalyst] Can't detach from root / create action object

Octavian Rasnita orasnita at gmail.com
Wed Nov 27 17:14:31 GMT 2013


From: "Craig Chant" <craig at homeloanpartnership.com>

> Hi Andre,
>
> That is clearer, and Alexander provided me with a working solution, but it 
> doesn't make sense with your example.
>
> $action is an action object isn't it?
>
> So Alexander's example has :-
>
> $c->detach($c->controller('ComplianceUpdate')->action_for('index'));
>
> So I assume
>
> $c->controller('ComplianceUpdate')->action_for('index');
>
> is returning an action object that is passed to detach.
>
> However, your example just has a string path '/a/my_action_1' , how is 
> that an action object?
>
> Are you  saying detach (for the single argument signature) takes a URL 
> path and that $action is just a string scalar with a URL path in it and 
> not an action object reference as I got the impression?



Below is a piece of text I created for the Catalyst documentation a long 
time ago (perldoc Catalyst).
It tries to makes the things a little bit clearer for using uri_for_action() 
method, but it is the same in any case an action path is used.
The idea is that even though the action path looks like a URL, it is not an 
URL. It is not the URL that calls that action.

""
        Note that although the path looks like a URI that dispatches to the
        wanted action, it is not a URI, but an internal path to that action.

        For example, if the action looks like:

         package MyApp::Controller::Users;

         sub lst : Path('the-list') {}

        You can use:

         $c->uri_for_action('/users/lst')

        and it will create the URI /users/the-list.
""

--Octavian




More information about the Catalyst mailing list