[Dbix-class] Question about belongs_to

Jon Molin jon.molin at gmail.com
Fri Dec 30 15:25:16 CET 2005


Hi list,

I tried the "Many-to-many relationships" example from the cookbok. It works
fine but I can't figure out how to name the belongs_to relation other than
the name of the column. That is:

__PACKAGE__->belongs_to('authID' => 'MyApp::DBIC::Author');

If I want to access the author by doing $obj->author, rather than
$obj->authID. I've tried:
__PACKAGE__->belongs_to ('author' => 'MyApp::DBIC::Author', undef,
'authID');# (have also tried with {'foreign.authID' => 'self.authID'})

But that just gives me a complaint saying there is no author method in
MyApp::DBIC::Book2Author. This confuses me as there is no problem naming
has_many relations. Is it not possible or do I call the belongs_to method
completely wrong?

/Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/dbix-class/attachments/20051230/5f4810ac/attachment.htm


More information about the Dbix-class mailing list