Controller Actions are only bound to urls by routes. Therefore the correct
way to refer to use url_for is via (named) routes and to do so by
name http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Named-routes
Hope that helps,
Joel
On Tuesday, September 26, 2017 at 12:03:35 AM UTC-5, nkukard wrote:
>
> Hi guys,
>
> I'm busy writing some plugins and I'm wondering what the right way to
> reference namespace, controller, actions would be.
>
>
> I've been looking over the code, and I was first using the following to
> reference all my links...
>
> url_for({"namespace" => "FOO", "controller" => "Admin::ModuleA::suba",
> "action" => "create"})
>
> Seemed like a good idea to always land up at the 100% correct link?
>
>
> But it looks like Mojolicious/Routes/Pattern.pm in sub render, it only
> searches the current tree.
>
> for my $token (reverse @{$self->tree}) {
>
>
> This seems, fine. But my reason for doing this is I am injecting URLs
> from one main plugin with multiple controllers using a before_render hook.
>
> Pretty much like a admin menu framework, where one can plugin smaller
> admin modules. So I am loading plugin FOO::Admin::ModuleA , for which I
> have two controllers suba and subb.
>
>
> My problem is that it seems to work well when I'm at the root path /,
> but the issue comes in when I am a bit deeper in, more specifically
> FOO::Admin::ModuleA::suba trying to url_for() links to actions in
> FOO::Admin::ModuleA::subb.
>
> When I am rendering the page for FOO::Admin::ModuleA::suba, my links
> don't work because $self->tree points to the current tree which has no
> children. So when I use my above url_for, I end up with the wrong result.
>
>
> Any advice?
>
>
> -N
>
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.