Skip to content

Instantly share code, notes, and snippets.

@hesco
Last active December 25, 2015 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hesco/886001682d449d78b30b to your computer and use it in GitHub Desktop.
Save hesco/886001682d449d78b30b to your computer and use it in GitHub Desktop.
What does this mean that my class 'is not a controller' and why is my $msg not making it into the stash?
$ less log/development.log --
[Wed Oct 9 16:38:32 2013] [debug] GET "/VolunteerOpportunities/Applicant/hesco/33".
[Wed Oct 9 16:38:32 2013] [debug] Class "VolunteerEngagement::VolunteerOpportunities::Applicant" is not a controller.
[Wed Oct 9 16:38:32 2013] [debug] Rendering template "volunteer_opportunities/applicant/application.html.ep".
[Wed Oct 9 16:38:32 2013] [error] Global symbol "$msg" requires explicit package name at template volunteer_opportunities/applicant/application.html.ep line 3.
1: % layout 'default';
2: % title 'Welcome';
3: <h2><%= $msg %></h2>
4: This page was generated from the template "templates/example/welcome.html.ep"
5: and the layout "templates/layouts/default.html.ep",
6: <a href="<%== url_for %>">click here</a> to reload the page or
7: <a href="/index.html">here</a> to move forward to a static page.
[Wed Oct 9 16:38:32 2013] [debug] Template "exception.development.html.ep" not found.
[Wed Oct 9 16:38:32 2013] [debug] Template "exception.html.ep" not found.
[Wed Oct 9 16:38:32 2013] [debug] Rendering cached inline template.
[Wed Oct 9 16:38:32 2013] [debug] Rendering cached inline template.
[Wed Oct 9 16:38:32 2013] [debug] 500 Internal Server Error (0.019361s, 51.650/s).
-----
http://127.0.0.1:3000/VolunteerOpportunities/Applicant/hesco/33 --
Stash:
{
'action' => 'application',
'appid' => '33',
'controller' => 'volunteer_opportunities-applicant',
'userid' => 'hesco'
}
-----
$ prove -lv t/routes.t --
ok 24 - GET /VolunteerOpportunities/Applicant/hesco/33
not ok 25 - 200 OK
# Failed test '200 OK'
# at t/routes.t line 32.
# got: '500'
# expected: '200'
-----
$ less t/routes.t --
$t->get_ok('/VolunteerOpportunities/Applicant/hesco/33')
->status_is(200);
-----
$ less lib/VolunteerEngagement.pm --
package VolunteerEngagement;
use Mojo::Base 'Mojolicious';
# This method will run once at server start
sub startup {
my $self = shift;
# Documentation browser under "/perldoc"
$self->plugin('PODRenderer');
# Router
my $r = $self->routes;
<snip>
# Authenticated access to an Applicant's Applications
$r->get('/VolunteerOpportunities/Applicant/:userid/:appid')
->to('volunteer_opportunities-applicant#application');
$r->get('/VolunteerOpportunities/Applicant/:user_name/:appid')
->to('volunteer_opportunities-applicant#application');
}
1;
-----
$ less lib/VolunteerEngagement/VolunteerOpportunities/Applicant.pm --
package VolunteerOpportunities::Applicant;
use Mojo::Base 'Mojolicious::Controller';
<snip>
sub application {
my $self = shift;
# Render template "volunteer_opportunities/applicant/application.html.ep" with message
$self->render(
msg => 'Hiring Committee Portal',
template => 'volunteer_opportunities/applicant/application',
);
}
1;
-----
$ ls templates/volunteer_opportunities/applicant/application.html.ep --
% layout 'default';
% title 'Welcome';
<h2><%= $msg %></h2>
This page was generated from the template "templates/example/welcome.html.ep"
and the layout "templates/layouts/default.html.ep",
<a href="<%== url_for %>">click here</a> to reload the page or
<a href="/index.html">here</a> to move forward to a static page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment