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

André Walker andre at andrewalker.net
Wed Nov 27 13:04:07 GMT 2013


On Wed, Nov 27, 2013 at 12:36:54PM +0000, Craig Chant wrote:
> No the documentation isn't clear, if I could understand it I wouldn’t be
> asking this question.

I'm sorry you couldn't understand from the documentation. I'll try and explain
a little more here:

# lib/MyApp/Controller/A.pm
package MyApp::Controller::A;
...

sub my_action_1 :Local {
     my ($self, $c) = @_;
     $c->res->body('in action 1');
}

sub my_action_2 :Local {
     my ($self, $c) = @_;
     $c->detach('my_action_1');
}

# lib/MyApp/Controller/B.pm
package MyApp::Controller::A;
...

sub other_action :Local {
     my ($self, $c) = @_;
     $c->detach('/a/my_action_1');
     # or
     $c->detach('MyApp::Controller::A', 'my_action_1');
}

Is it clearer now?

Cheers!
André




More information about the Catalyst mailing list