I am trying to come up with a way to manage roles for users in my Catalyst app, I have a database structure much like what is used in Chapter 5 of the Catalyst::Manual::Tutorial &lt;<meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="http://search.cpan.org/~bobtfish/Catalyst-Manual-5.8007/lib/Catalyst/Manual/Tutorial/05_Authentication.pod">http://search.cpan.org/~bobtfish/Catalyst-Manual-5.8007/lib/Catalyst/Manual/Tutorial/05_Authentication.pod</a>&gt; where I have a user table, a role table, and and a usertorole table.  I am trying to find a way to get a list of roles for a user to be able to make changes, add new roles and/or remove roles from the user.  I have both authentication and authorization working in my app and I can fetch the roles for the user currently logged in by <div>
<br></div><div>&lt;ul&gt;</div><div>[% FOR role = c.user.roles %]&lt;li&gt;[% role %]&lt;/li&gt;[% END %]</div><div>&lt;/ul&gt;</div><div><br></div><div>But when I try to get a list from a different user it doesn&#39;t work as expected, here is what I am currently doing</div>
<div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><pre style="word-wrap: break-word; white-space: pre-wrap; ">
sub base : Chained(&#39;/&#39;): PathPart(&#39;admin&#39;) :CaptureArgs(0) {
        my ( $self, $c ) = @_;
        
        $c-&gt;stash( users_rs =&gt; $c-&gt;model(&#39;DB::User&#39;));
        $c-&gt;stash( role_rs =&gt; $c-&gt;model(&#39;DB::Role&#39;));
        $c-&gt;stash( usertorole_rs =&gt; $c-&gt;model(&#39;DB::Userstorole&#39;));
}</pre><pre style="word-wrap: break-word; white-space: pre-wrap; "><br></pre><pre style="word-wrap: break-word; white-space: pre-wrap; "><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; white-space: normal; "><pre style="word-wrap: break-word; white-space: pre-wrap; ">
sub user : Chained(&#39;base&#39;): CaptureArgs(1) {
        my ( $self, $c, $uniqid ) = @_;

        if ( $uniqid == m/[^0-9]/ ) {
                die &quot;The ID number is not numeric\n&quot;;
        }
        my $user = $c-&gt;stash-&gt;{users_rs}-&gt;find({ uniqid =&gt; $uniqid });
        die &quot;No such user: $uniqid\n&quot; if (!$user);
        my $roles = $c-&gt;stash-&gt;{usertorole_rs}-&gt;search(
                undef,
                {
                               where =&gt; { &#39;userid&#39;, $uniqid }
                },
        );
        warn &quot;No such role: $uniqid\n&quot; if (!$roles);
        $c-&gt;stash(user =&gt; $user,
                roles =&gt; $roles);
}</pre><pre style="word-wrap: break-word; white-space: pre-wrap; "><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: helvetica, arial, freesans, clean, sans-serif; font-size: 11px; line-height: 14px; white-space: normal; "><pre style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font: normal normal normal 12px/normal Monaco, &#39;Courier New&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, monospace; line-height: 1.4em; font-family: &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace; font-size: 12px; ">
<div class="line" id="LC19" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; ">[% FOR role IN roles %]</div>
<div class="line" id="LC20" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; ">                &lt;tr&gt;&lt;td&gt;Role #:&lt;/td&gt;&lt;td&gt;Role [% role.role %] Role ID [% role.roleid %] User id [% role.userid %]&lt;/td&gt;&lt;/tr&gt;</div>
<div class="line" id="LC21" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 1em; line-height: 1.4em; ">[% END %]</div>
</pre></span></pre></span></pre></span></div><div>My database schema is so</div><div><br></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><pre style="word-wrap: break-word; white-space: pre-wrap; ">
CREATE TABLE roles (
    uniqid integer NOT NULL,
    role character varying(32) NOT NULL
);
</pre><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><pre style="word-wrap: break-word; white-space: pre-wrap; ">CREATE TABLE users (
    uniqid integer NOT NULL,
    username character varying(20) NOT NULL,
    password character varying(40) NOT NULL,
    firstname character varying(20) NOT NULL,
    lastname character varying(20) NOT NULL,
    email character varying(20) NOT NULL,
    active boolean DEFAULT true NOT NULL,
    created timestamp without time zone DEFAULT now() NOT NULL
);</pre><pre style="word-wrap: break-word; white-space: pre-wrap; "><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; white-space: normal; "><pre style="word-wrap: break-word; white-space: pre-wrap; ">
CREATE TABLE userstoroles (
    userid integer NOT NULL,
    role integer NOT NULL
);</pre><pre style="word-wrap: break-word; white-space: pre-wrap; "><br></pre><pre style="word-wrap: break-word; white-space: pre-wrap; ">Am I going about this the wrong way or is there something that I am over looking?</pre>
</span></pre></div></span></div>