The 'account.account_id' referenced in your template I believe is being interpreted as an object. Try 'account.account_id.id' instead. I am presuming that your DBIC relationship is called 'account_id', and that is what you are referencing currently in your template.

On 5/8/2012 11:13 AM, Kenneth S Mclane wrote:
I am having a problem with my code and I cannot figure out why it is doing what it is doing. I have this sub:

sub list :Local {
        my ($self, $c, $page) = @_;
        $page = $c->req->param('page') || 1;
        my $rs = $c->model('ORANGES::Account')->search({}, {
                join => 'progress',
                '+select' => ['progress.percent_complete'],
                '+as' => ['progress.percent_complete'],
                join => 'compliance',
                '+select' => ['compliance.percent_compliant'],
                '+as' => ['compliance.percent_compliant'],
                join => 'department_id',
                '+select' => ['department_id.department_id'],
                '+as' => ['department_id.department_id'],
                join => 'metrics',
'+select' => ['metrics.num_servers','metrics.num_subsystems'], '+as' => ['metrics.num_servers','metrics.num_subsystems'],
                order_by => 'account_code',
                rows => 15,
                page => $page,
         });
        $c->stash(accounts => $rs);
        $c->stash(pager => $rs->pager());
        $c->stash->{'template'}=>'accountview/list';

}
Which I have tried in several different ways to fix this problem, but none have worked so far. In my template file all my fields come up with the valyes expected, except, I am trying to use the account_id field value as part of a uri to take the user to a details page for the row. Where I am expecting a uri such as 'http://127.0.0.1:3000/accountdetails/detail/170'
I instead get a uri like this:

http://127.0.0.1:3000/accountdetails/detail/dbms::Model::ORANGES::Account=HASH%280x5496460%29

This used to work when I was using a view as the basis for my list page.

When I run the page I can see in the sub-queries that it runs that it has the "account_id" value as it uses it, but when I try to access it in my template I get the hash ref. None of the other fields do this.

one of the sub queries using the account_id value:
SELECT me.account_id, me.account_code, me.percent_compliant FROM HCDB_TEST.COMPLIANCE me WHERE ( me.account_id = ? ): '321'


My template that cretaes the uri:

<td><a href="[% c.uri_for('/accountdetails/detail/') %][% account.account_id %]">[% account.account_code %]</a></td>

If someone could point me in the right direction, Ive been fighting this for days.



_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to