Greetings, In the following example how will you make MyApp::Model::Users have access to app object (which is basically $self) that is necessary to use app->db and app->config?
http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#WELL-STRUCTURED-APPLICATION <http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#WELL-STRUCTURED-APPLICATION> package MyApp; use Mojo::Base 'Mojolicious'; use MyApp::Model::Users; sub startup { my $self = shift; $self->secrets(['Mojolicious rocks']); $self->helper(users => sub { state $users = MyApp::Model::Users->new }); my $r = $self->routes; $r->any('/' => sub { my $c = shift; my $user = $c->param('user') || ''; my $pass = $c->param('pass') || ''; return $c->render unless $c->users->check($user, $pass); $c->session(user => $user); $c->flash(message => 'Thanks for logging in.'); $c->redirect_to('protected'); } => 'index'); my $logged_in = $r->under(sub { my $c = shift; return 1 if $c->session('user'); $c->redirect_to('index'); return undef; }); $logged_in->get('/protected'); $r->get('/logout' => sub { my $c = shift; $c->session(expires => 1); $c->redirect_to('index'); }); } 1; Cheers Eugene -- 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 mojolicious+unsubscr...@googlegroups.com. To post to this group, send email to mojolicious@googlegroups.com. Visit this group at http://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.