Per request of another Monk I am reposting my Catalyst question. I am new to Catalyst development and I am trying to create a View that displays the contents of a single table in my database, sort of like a "system users" page.
This is what I have in my controller:

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, $yd +ay, $isdst ) = localtime time; $year += 1900; my @month_abbr = qw( Jan Feb Mar Apr May Jun Jul Aug S +ep 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 creatio +n" ); $c->stash->{error_msg} = 'Invalid email addres +s in user creation'; return; } $Data::Dumper::Useperl = 1; } }

The create subroutine works and I am able to add new entries to my database, but the list doesn't display anything. Here is what I get from the Catalyst server:

[info] *** Request 1 (0.167/s) [19733] [Tue Mar 29 20:49:35 2011] *** + + + [debug] "GET" request for "admin/list" from "192.168.1.3" + + + [debug] Path is "/admin/list" + + + [debug] *** INSIDE BASE METHOD *** + + + [debug] *** INSIDE LIST METHOD users = 1 *** + + + [debug] Rendering template "admin/list.tt2" + + + [debug] Response Code: 200; Content-Type: text/html; charset=utf-8; Co +ntent-Length: 1546 + + [info] Request took 0.131545s (7.602/s)

Here is what my list.tt2 contains:

[% META title = 'System Users List' -%] <table> <tr><th>ID</th><th>firstname</th><th>lastname</th><th>email</th><th>ph +one</th><th>Management Rating</th><th>Comments</th><th>Date</th><th>A +dmin</th></tr> [% FOR tech IN users.all -%] <tr> <td>[% users.id %]</td> <td>[% users.firstname %]</td> <td>[% users.lastname %]</td> <td>[% users.phone %]</td> <td>[% users.email %]</td> <td>[% users.phone %]</td> <td>[% users.managementrating %]</td> <td>[% users.managementcomments %]</td> <td>[% users.date %]</td> <td>[% users.ismanagement %]</td> </tr> [% END -%] </table> <pre> Dump of the 'users' variable: [% Dumper.dump(users) %] </pre>

In reply to Can't retrieve data in a catalyst controller by vendion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.