On 12/30/05, <b class="gmail_sendername">Jon Molin</b> <<a href="mailto:jon.molin@gmail.com">jon.molin@gmail.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi list,<br>
<br>
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:<br>
<br>
__PACKAGE__->belongs_to('authID' => 'MyApp::DBIC::Author');<br>
<br>
If I want to access the author by doing $obj->author, rather than $obj->authID. I've tried:<br>
__PACKAGE__->belongs_to ('author' => 'MyApp::DBIC::Author',
undef, 'authID');# (have also tried with {'foreign.authID' =>
'self.authID'})<br>
<br>
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?<br><span class="sg"><span>
<br></span></span></blockquote></div>If I'm understanding the question correctly, I think what you are looking for is:<br>__PACKAGE__->belongs_to('author', 'MyApp::DBIC::Author', 'authID');<br clear="all"><br>-- <br>Jason Kohles
<br><a href="mailto:email@jasonkohles.com">email@jasonkohles.com</a> - <a href="http://www.jasonkohles.com/">http://www.jasonkohles.com/</a><br>"A witty saying proves nothing." -- Voltaire<br>