<font size=2 face="sans-serif">Here are the two relationships predefined
in the account.pm file:</font>
<br>
<br><font size=2 face="sans-serif">__PACKAGE__->belongs_to(</font>
<br><font size=2 face="sans-serif"> "account_id",</font>
<br><font size=2 face="sans-serif"> "dbms::Schema::Result::Account",</font>
<br><font size=2 face="sans-serif"> { account_id => "account_id"
},</font>
<br><font size=2 face="sans-serif">);</font>
<br>
<br><font size=2 face="sans-serif">=head2 accounts</font>
<br>
<br><font size=2 face="sans-serif">Type: has_many</font>
<br>
<br><font size=2 face="sans-serif">Related object: L<dbms::Schema::Result::Account></font>
<br>
<br><font size=2 face="sans-serif">=cut</font>
<br>
<br><font size=2 face="sans-serif">__PACKAGE__->has_many(</font>
<br><font size=2 face="sans-serif"> "accounts",</font>
<br><font size=2 face="sans-serif"> "dbms::Schema::Result::Account",</font>
<br><font size=2 face="sans-serif"> { "foreign.account_id"
=> "self.account_id" },</font>
<br><font size=2 face="sans-serif"> {},</font>
<br><font size=2 face="sans-serif">);</font>
<br><font size=2 face="sans-serif"> </font>
<br><font size=2 face="sans-serif">So you're saying I should do this:</font>
<br>
<br><font size=2 face="sans-serif">__PACKAGE__->belongs_to(</font>
<br><font size=2 face="sans-serif"> "account",</font>
<br><font size=2 face="sans-serif"> "dbms::Schema::Result::Account",</font>
<br><font size=2 face="sans-serif"> { account_id => "account_id"
},</font>
<br><font size=2 face="sans-serif">);</font>
<br>
<br><font size=2 face="sans-serif">?</font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">From:</font>
<td><font size=1 face="sans-serif">Will Crawford <billcrawford1970@gmail.com></font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">To:</font>
<td><font size=1 face="sans-serif">The elegant MVC web framework <catalyst@lists.scsys.co.uk></font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Date:</font>
<td><font size=1 face="sans-serif">05/08/2012 10:49 AM</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Subject:</font>
<td><font size=1 face="sans-serif">Re: [Catalyst] Getting hashref instead
of value</font></table>
<br>
<hr noshade>
<br>
<br>
<br><font size=3><br>
</font>
<br><font size=3>On 8 May 2012 16:44, Kenneth S Mclane <</font><a href=mailto:ksmclane@us.ibm.com target=_blank><font size=3 color=blue><u>ksmclane@us.ibm.com</u></font></a><font size=3>>
wrote:</font>
<br><font size=3 face="sans-serif">The Catalyst helper script created most
of the relationships. I added a few at the bottom of the Account.pm file
to since there are a bunch of them based on "account_id", so
I made them myself and gave them different names. progress, metrics, compliance
are ones I did. the one called "department_id" was created by
the helper and I didn"t want to chang it. I guess I could redefine
it below with a different name. Strangely, the account table has a belongs
to AND a has many to itself based on the account_id field. I am actually
looking to get a list nad that is what I get except for the one field.</font><font size=3>
</font>
<br>
<br><font size=3>Basically you just need to rename the relationship to
call the accessor "account" instead of "account_id",
so that .account_id refers to the raw ID column, not the object.</font><tt><font size=2>_______________________________________________<br>
List: Catalyst@lists.scsys.co.uk<br>
Listinfo: </font></tt><a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst"><tt><font size=2>http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</font></tt></a><tt><font size=2><br>
Searchable archive: </font></tt><a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/"><tt><font size=2>http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</font></tt></a><tt><font size=2><br>
Dev site: </font></tt><a href=http://dev.catalyst.perl.org/><tt><font size=2>http://dev.catalyst.perl.org/</font></tt></a><tt><font size=2><br>
</font></tt>
<br>
<br>