Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: First steps with Mojolicious

by frazap (Monk)
on May 01, 2019 at 14:38 UTC ( [id://1233231]=note: print w/replies, xml ) Need Help??


in reply to First steps with Mojolicious

I changed a few things and did some progress (I think)...

First, rename the whole thing from Lib to MyLib and reread the doc

My +folders are now
run.pl my_lib.conf +templates common_js.html.ep invtot.html.ep libmap.html.ep +layouts default.html.ep +public index.html some .js files +lib MyLib.pm +MyLib Invtot.pm +Controller Invtot.pm
I have the post action starting until it crashes on the line trying to fetch the database handler which is get from startup in package MyLib::Invtot. The whole file is
package MyLib::Invtot; use Mojo::Base 'Mojolicious'; sub startup { my $app = shift; my $config = $app->config; $app->log->debug("connecting..."); $app->plugin( 'Database', { dsn => 'dbi:mysql:host=mysql.unifr.ch:dbname=dokpe_i0 +1', username => $config->{username}, password => $config->{password}, options => { 'pg_enable_utf8' => 1, AutoCommit => 1, PrintError => 0, RaiseError => 1 }, helper => 'db', } ); } 1;
and the call to helper => db should make it accessible to the controller in MyLib/Controller/Invtot. That's not the case and I'm not even sure it's called at all. How can I make sure the connection is made the first time the invtot page is load and how can I then retrieve the database connection in the controller ?

Thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1233231]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-19 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found