[jifty-devel] accessing Left and Right models through link table
(LeftRight)
Matthew Lenz
matthew at nocturnal.org
Thu Jul 12 22:22:54 EDT 2007
I've got a couple models and a link table as described in the trunk
version of the Cookbook for implementing a many-to-many relationship.
I'm having difficulty accessing information in the respective models
through the link table collection.
I've tried a couple different methods where $id is the left id.
First try:
$collection = MyApp::Model::LeftRightCollection->new();
$collection->limit(column => "left", value => $id);
while (my $left_right = $collection->next) {
print $left_right->right->name;
}
Second try:
$left = MyApp::Model::Left->new();
$left->load($id);
$collection = $left->right;
while (my $left_right = $collection->next) {
print $left_right->right->name;
}
To me both of these seem equivalent but both complain that object method
'name' cannot be accessed via MyApp::Model::LeftRightCollection.
More information about the jifty-devel
mailing list