[Dbix-class] The Definitive Guide to Catalyst ... p. 165 listing all users and their roles

Robyn Jonahs learn.catalyst at gmail.com
Thu Jul 12 15:30:03 GMT 2012


On Thu, Jul 12, 2012 at 3:26 AM, Patrick Meidl <patrick at pantheon.at> wrote:

> On Wed, Jul 11 2012, Robyn Jonahs <learn.catalyst at gmail.com> wrote:
>
> >         <ul>
> >           [% FOREACH role =3D user.user_roles %]
> >             <li>[% role.role_id.role %]</li>
> >           [% END %]
> >         </ul>
>
> try this:
>
> <ul>
>   [% FOREACH role =3D 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
>
>
Thanks, this also worked.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20120712/669=
6e77a/attachment.htm


More information about the DBIx-Class mailing list