[Catalyst] accessing ResultSet function from a related object
John Goulah
jgoulah at gmail.com
Wed Jul 4 21:09:41 GMT 2007
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20070704/8e60a=
a78/attachment.htm
More information about the Catalyst
mailing list