sub base : Chained('/'): PathPart('admin'): CaptureArgs(0) { my ($self, $c) = @_; $c->stash( users_rs => $c->model('DB::Tech')); $c->log->debug('*** INSIDE BASE METHOD ***'); } sub list :Chained('base') :PathPart('list') :Args(0) { my ($self, $c) = @_; my ($users) = $c->model('DB::Tech')->search_rs; $c->stash( users => $users ); $c->stash(template => 'admin/list.tt2'); $c->log->debug("*** INSIDE LIST METHOD users = $users ***"); } sub create : Chained('base'): PathPart('create'): Args(0) { my ($self, $c) = @_; if(lc $c->req->method eq 'post') { # Retrieve the values fro mthe form my $params = $c->req->params; my $users_rs = $c->stash->{users_rs}; my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime time; $year += 1900; my @month_abbr = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ); my $date = "$year-$month_abbr[$mon]-$mday"; my $newuser = eval { $users_rs->create({ username => $params->{username}, password => $params->{password}, fname => $params->{fname}, lname => $params->{lname}, email => $params->{email}, phone => $params->{phone}, managementrating => '5', managementcomments => q[], date => $date, ismanagement => '0', }) }; if($@) { $c->log->debug( "Invalid email address in user creation" ); $c->stash->{error_msg} = 'Invalid email address in user creation'; return; } $Data::Dumper::Useperl = 1; } }