[Dbix-class] The Definitive Guide to Catalyst ... p. 165 listing
all users and their roles
Patrick Meidl
patrick at pantheon.at
Thu Jul 12 07:26:32 GMT 2012
On Wed, Jul 11 2012, Robyn Jonahs <learn.catalyst at gmail.com> wrote:
> <ul>
> [% FOREACH role = user.user_roles %]
> <li>[% role.role_id.role %]</li>
> [% END %]
> </ul>
try this:
<ul>
[% FOREACH role = user.roles %]
<li>[% role.id %] [% role.role %]</li>
[% END %]
</ul>
explanation: in your User Result class, you have a many_to_many called
'roles' which returns the Role's associated with the user (joining via
the user_role table), then you can call the accessors on the Role object
to display the data you need.
HTH
patrick
--
Patrick Meidl ........................ patrick at pantheon.at
Vienna, Austria ...................... http://gplus.to/pmeidl
More information about the DBIx-Class
mailing list