in reply to Can't retrieve data in a catalyst controller

This is a little fishy–

my ($users) = $c->model('DB::Tech')->search_rs; # No parens necessary or desired, it returns just a ResultSet. my $users = $c->model('DB::Tech')->search_rs;

–but it won’t cause a problem either way.

Debugging / general pointers–

New controller method (PathPart is fine to be explicit but it is redundant here because it’s the same as the method name; and the template setting might even be superfluous)–

sub list :Chained('base') :Args(0) { my ( $self, $c ) = @_; $c->stash(template => 'admin/list.tt2'); } # OR this is likely to work if your TT stuff is configured right- sub list :Chained('base') :Args(0) {}

Now the template. Compare the var names in the loop below to your version. users_rs is already in the stash from chaining off of admin/base. You might want to stop referring to them as techs. It does seem to cause some problems. :)

[% 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 user IN users_rs.all -%] <tr> <td>[% user.id %]</td> <td>[% user.firstname | html %]</td> <td>[% user.lastname | html %]</td> <td>[% user.phone | html %]</td> <td>[% user.email | html %]</td> <td>[% user.phone | html %]</td> <td>[% user.managementrating | html %]</td> <td>[% user.managementcomments | html %]</td> <td>[% user.date %]</td> <td>[% user.ismanagement %]</td> </tr> [% END -%] </table>

Replies are listed 'Best First'.
Re^2: Can't retrieve data in a catalyst controller
by vendion (Scribe) on Mar 30, 2011 at 19:16 UTC

    Thank you for the help, it is working now.

Re^2: Can't retrieve data in a catalyst controller
by vendion (Scribe) on Apr 13, 2011 at 02:21 UTC

    Ok so one question I have is in the template why did it matter when the for loop was called as [% FOR user IN users_rs.all -%] I'm just trying to understand why it had to be 'user' when I am not setting anything like this in my code. I am trying to understand so I will know for future reference. I can't seem to find a good answer to this anywhere

      It doesn't have to be $user.

      FOR user IN users_rs.all
      is like
      for my $user (users_rs->all)

      What ikegami said, plus make sure to read your original code–

      [% FOR tech IN users.all -%] <tr> <td>[% users.id %]</td>

      The problem is you called each object in the resultset tech but tried to access it as users. This would be fine too–

      [% FOR tech IN users.all -%] <tr> <td>[% tech.id %]</td>

      I was joking above about keeping it consistent (always calling them user) because it has led to confusion a couple of times, not that tech is somehow wrong.