[Catalyst] (Beginner) Problem listing users in DB

Steffen Kremsler mls at truthdoesntexist.org
Sat Oct 21 21:07:53 CEST 2006


Hi.

I'm stuck with a strange problem. First I worked through the Tutorial
and got it running without problems. Then i added a new controller and 
template
to list the users in the db. I did that the same way as with the the 
books controller.
But it doesn't output the user roles. I have rechecked everything ...
dozens of times but i don't see an error in my controller or template.

Authentification and authorization do work though, and a

   [% FOR role = Catalyst.user.roles %][% role %] [% END %]

in the Template puts out roles correctly. So the error can't be in the
DB Model, right?

Controller:
-----------
sub list : Local {
   my ($self, $c) = @_;
   $c->stash->{users} = [$c->model('MyAppDB::User')->all];
}

So i can access user.id and user.username in the template but
user.roles is empty. Am I overlooking something? What am I doing wrong?

users/list.tt2:
---------------
<table>
<tr>
 <th>ID</th>
 <th>Username</th>
 <th>Roles</th>
</tr>
[% # Display each user in a table row %]
[% FOREACH user IN users -%]
<tr>
 <td>[% user.id %]</td>
 <td>[% user.username %]</td>

 <!-- why is user.roles empty -->
 <td>[% tt_roles = [ ]; tt_roles.push(role.role) FOREACH role = 
user.roles %]
     [% tt_roles.join(', ') %]</td>
</tr>
[% END -%]
</table>

I'm thankfull for every tip you can give.

Greetings,
Steffen K.



More information about the Catalyst mailing list