<font size=2 face="sans-serif">In checking through docs on line I find
that prefetch is a better way to go so I have changed ny sub thusly:</font>
<br>
<br><font size=2 face="sans-serif">sub list :Local {</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; my
($self, $c, $page) = @_;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; $page
= $c-&gt;req-&gt;param('page') || 1;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; my
$rs = $c-&gt;model('ORANGES::Account')-&gt;search({}, { </font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; prefetch =&gt; 'progress',</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; prefetch =&gt; 'compliance',</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; prefetch =&gt; 'department_id',</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; prefetch =&gt; 'metrics',</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; order_by =&gt; 'account_code',</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; rows =&gt; 15,</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; page =&gt; $page,</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;});</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; $c-&gt;stash(accounts
=&gt; $rs);</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; $c-&gt;stash(pager
=&gt; $rs-&gt;pager());</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; $c-&gt;stash-&gt;{'template'}=&gt;'accountview/list';</font>
<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">Frank Schwach &lt;fs5@sanger.ac.uk&gt;</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">To:</font>
<td><font size=1 face="sans-serif">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:36 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><tt><font size=2>not sure if this is a problem but you should also
collapse your joins, <br>
selects and as' into ArrayRefs, as in<br>
join =&gt; [ qw( progress compliance department_id ...)]<br>
<br>
actually the last one looks suspicious. the relationships should be <br>
called something like &quot;departments&quot;, not department_ids. If you
have the <br>
same naming for accounts then an account_id is the name (presumably) of
<br>
a field in accounts and also a relationship<br>
Frank<br>
<br>
<br>
On 08/05/12 16:25, Steve wrote:<br>
&gt; The 'account.account_id' referenced in your template I believe is
being<br>
&gt; interpreted as an object. Try 'account.account_id.id' instead. I am<br>
&gt; presuming that your DBIC relationship is called 'account_id', and
that<br>
&gt; is what you are referencing currently in your template.<br>
&gt;<br>
&gt; On 5/8/2012 11:13 AM, Kenneth S Mclane wrote:<br>
&gt;&gt; I am having a problem with my code and I cannot figure out why
it is<br>
&gt;&gt; doing what it is doing. I have this sub:<br>
&gt;&gt;<br>
&gt;&gt; sub list :Local {<br>
&gt;&gt; my ($self, $c, $page) = @_;<br>
&gt;&gt; $page = $c-&gt;req-&gt;param('page') || 1;<br>
&gt;&gt; my $rs = $c-&gt;model('ORANGES::Account')-&gt;search({}, {<br>
&gt;&gt; join =&gt; 'progress',<br>
&gt;&gt; '+select' =&gt; ['progress.percent_complete'],<br>
&gt;&gt; '+as' =&gt; ['progress.percent_complete'],<br>
&gt;&gt; join =&gt; 'compliance',<br>
&gt;&gt; '+select' =&gt; ['compliance.percent_compliant'],<br>
&gt;&gt; '+as' =&gt; ['compliance.percent_compliant'],<br>
&gt;&gt; join =&gt; 'department_id',<br>
&gt;&gt; '+select' =&gt; ['department_id.department_id'],<br>
&gt;&gt; '+as' =&gt; ['department_id.department_id'],<br>
&gt;&gt; join =&gt; 'metrics',<br>
&gt;&gt; '+select' =&gt; ['metrics.num_servers','metrics.num_subsystems'],<br>
&gt;&gt; '+as' =&gt; ['metrics.num_servers','metrics.num_subsystems'],<br>
&gt;&gt; order_by =&gt; 'account_code',<br>
&gt;&gt; rows =&gt; 15,<br>
&gt;&gt; page =&gt; $page,<br>
&gt;&gt; });<br>
&gt;&gt; $c-&gt;stash(accounts =&gt; $rs);<br>
&gt;&gt; $c-&gt;stash(pager =&gt; $rs-&gt;pager());<br>
&gt;&gt; $c-&gt;stash-&gt;{'template'}=&gt;'accountview/list';<br>
&gt;&gt;<br>
&gt;&gt; }<br>
&gt;&gt; Which I have tried in several different ways to fix this problem,
but<br>
&gt;&gt; none have worked so far. In my template file all my fields come
up<br>
&gt;&gt; with the valyes expected, except, I am trying to use the account_id<br>
&gt;&gt; field value as part of a uri to take the user to a details page
for<br>
&gt;&gt; the row. Where I am expecting a uri such as<br>
&gt;&gt; 'http://127.0.0.1:3000/accountdetails/detail/170'<br>
&gt;&gt; I instead get a uri like this:<br>
&gt;&gt;<br>
&gt;&gt; </font></tt><a href="http://127.0.0.1:3000/accountdetails/detail/dbms::Model::ORANGES::Account=HASH%280x5496460%29"><tt><font size=2>http://127.0.0.1:3000/accountdetails/detail/dbms::Model::ORANGES::Account=HASH%280x5496460%29</font></tt></a><tt><font size=2><br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; This used to work when I was using a view as the basis for my
list page.<br>
&gt;&gt;<br>
&gt;&gt; When I run the page I can see in the sub-queries that it runs
that it<br>
&gt;&gt; has the &quot;account_id&quot; value as it uses it, but when I
try to access it<br>
&gt;&gt; in my template I get the hash ref. None of the other fields do
this.<br>
&gt;&gt;<br>
&gt;&gt; one of the sub queries using the account_id value:<br>
&gt;&gt; SELECT me.account_id, me.account_code, me.percent_compliant FROM<br>
&gt;&gt; HCDB_TEST.COMPLIANCE me WHERE ( me.account_id = ? ): '321'<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; My template that cretaes the uri:<br>
&gt;&gt;<br>
&gt;&gt; &lt;td&gt;&lt;a href=&quot;[% c.uri_for('/accountdetails/detail/')
%][%<br>
&gt;&gt; account.account_id %]&quot;&gt;[% account.account_code %]&lt;/a&gt;&lt;/td&gt;<br>
&gt;&gt;<br>
&gt;&gt; If someone could point me in the right direction, Ive been fighting<br>
&gt;&gt; this for days.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; List: Catalyst@lists.scsys.co.uk<br>
&gt;&gt; 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>
&gt;&gt; Searchable archive:<br>
&gt;&gt; </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>
&gt;&gt; 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>
&gt;<br>
&gt; _______________________________________________<br>
&gt; List: Catalyst@lists.scsys.co.uk<br>
&gt; 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>
&gt; 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>
&gt; 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>
<br>
<br>
-- <br>
 The Wellcome Trust Sanger Institute is operated by Genome Research <br>
 Limited, a charity registered in England with number 1021457 and a <br>
 company registered in England with number 2742969, whose registered <br>
 office is 215 Euston Road, London, NW1 2BE. <br>
<br>
_______________________________________________<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>
<br>
</font></tt>
<br>
<br>