[Catalyst] accessing ResultSet function from a related object

John Goulah jgoulah at gmail.com
Wed Jul 4 22:48:08 GMT 2007


On 7/4/07, Ash Berlin <ash_cpan at firemirror.com> wrote:
>
> John Goulah wrote:
> > I am having some trouble in both controller and template code accessing
> > resultset functions off of chained/related objects (because from what
> > I'm seeing they are not ResultSets but of the type
> > MyApp::Model::MyAppDB::Tablename).
> >
> > For example I can create a ResultSet object directly like:
> >     my $owner =3D $c->model('MyDB::User')->search({ user_id =3D> $owner=
_id }
> );
> >
> > and then I can do for example:
> >
> >     $owner->some_result_set_method()
> >
> > but I can't do this if I want to chain off another object, such as:
> >
> >     #not ok
> >     my $owner_id =3D
> > $photo_details_rs->first()->owner->some_result_set_method();
> >
> > but...
> >
> >     #this is fine, just accessing a field
> >     my $owner_id =3D $photo_details_rs->first()->owner->user_id;
> >
> > and if I have some relation such as 'primary_photo' defined, then in my
> > template this is also ok on this model type object:
> >
> >        comment.user.primary_photo.asset.url
> >
> > but if I wanted to call a method defined in my ResultSet, its not
> working:
> >
> >     comment.user.some_result_set_method
> >
> >
> > I understand this is because comment.user is of type Model, but it seems
> > there would be some way to call these functions since in this case I
> > need to get at the user object from each comment since thats whats being
> > iterated-
> >
> > Thanks,
> > John
> >
>
> Wrong list entirely. You are asking what appears to be a DBIx::Class
> question: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class



Reposted on dbix::class list....
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070704/ef80c=
cef/attachment.htm


More information about the Catalyst mailing list