[Dbix-class] Chaining multiple many-to-many relations

Jon jon at texttoall.com
Wed Dec 15 15:37:57 GMT 2010


> I'd like to use a shortcut of the form :
> my $rsApplications=$rowUser->groups->applications
>
> But it does not seem to work. I get this error :  Can't locate object
> method "applications" via package "DBIx::Class::ResultSet"

The result of $rowUser->groups is a DBIx::Class::ResultSet...so it's a
collection of your "groups", not an actual "group".  You can only call
ResultSet methods on it like, next, and count.  If you want to get to
your actual group object, which is where you can then call
"applications", you need to address the actual result object.  e.g.
my $groups = $rowUser->groups;
while ( my $group = $groups->next ) {
   my $applications = $group->applications;
    while ( my $app = $applications->next ) {
       # doing awesome app stuff
   }
}

Hope that helps.

- jon



More information about the DBIx-Class mailing list