On 02/04/2015 09:23 AM, Peter Rabbitson wrote:
On 02/04/2015 06:14 PM, Chris Welch wrote:
...
However, in my template (having stashed |$divisions|), I'm unable to
access the grid_positions_filled object because division.team_seaons
gives me an arrayref of team resultsets in that division:
[%
# Loop through our divisions
FOREACH division IN divisions;
CALL c.log.debug(division.team_seasons); # The output of this is
something like: ARRAY(0x6f8318c)
END;
-%]
...
Any relationship accessor is also created with an <accessor_name>_rs
variant, to work around *exactly* this (mis)feature of TT.
What you want above is ...division.team_seasons_rs...
Cheers
And to expound on *why* this is happening... TT works in list context by
default, so anything that can return a list of values will do so.
Meaning those resultset calls (which usually come down to search()'s)
return lists of rows versus another resultset object.
There are a couple of ways to tell TT to work in scalar context, one of
which Peter described above. Another is to use TT's Scalar plugin [1]
and do something like ...division.scalar.team_seasons...
I'd be interested in about hearing folks' experiences/pros/cons of using
_rs vs scalar vs ??? in TT.
--Trevor
[1] http://www.tt2.org/docs/modules/Template/Plugin/Scalar.html
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk