Leandro:<br>> you don't need to use Data::Page directly <br><br>yes, you are quite right, I took out the<br>explicit call to Data::Page; I set rows => 2,<br>and my query gets 2 thumbs. Cool.<br><br>>you are setting $c->stash->{photos} to an <br>>array reference when you do <br>>$c->stash->{photos} = [$c->model( ... ]; <br>>and then you are later trying to make a <br>>method call ->pager() on that array reference, <br>>not an object. <br><br>With the square brackets, I get an array ref, <br>and in my template, I do stuff like:<br>[% FOREACH photo IN photos -%]<br>[% photo.gallery.name %]<br>[% END -%]<br><br>When I take the square brackets out of the<br>query, my template doesn't display anything<br>anymore. <br><br>>See the "Paged Results" section of the <br>>DBIx::Class::Manual::Cookbook POD on<br>>CPAN.<br><br>which of course I'd been trying to beat <br>into my forehead. Cookbook says:<br>"you can return a Data::Page
object for the resultset <br>(suitable for use in e.g. a template) <br>using the pager method:<br><br>return $rs->pager();"<br><br>So I'm trying to call the pager method from the<br>resultset. But translating from the cookbook<br>example (which is non-Catalyst centric) to <br>Cat code, falls the shadow.<br><br>Chisel:<br>>$c->stash->{pager} => $c->stash->{photos}->pager();<br>>shouldn't this be an assignment rather than a fat-comma?<br><br>Good eyeballs! Yes. <br><br>>I think you need to lose the square brackets, <br>>and you will probably find you then have a <br>>DBIx::Class::ResultSet, which does have the <br>>pager() method. <br><br>When I do, I get this error:<br>Caught exception in Catapult::Controller::Photo::Gallery->display "DBIx::Class::ResultSet::pager(): Can't create pager for non-paged rs<br><br>Going back to the DBIx::Class Cookbook example, <br>which is pretty simple (no joins or anything), do I <br>have the joins
and the row settings in the right place? <br>I tried a few combos, and the one that at least doesn't <br>throw cat down the stairs is the one I have been using:<br><br> $c->stash->{photos} = [$c->model('CatapultDB::Photos')->search(<br> {<br> 'gallery.id' => $selected_gallery<br> },<br> {<br> join => [qw/ gallery /],<br> prefetch => [qw/ gallery /],<br> rows => 2,<br> }<br> )];<br><br>Much less hair now,<br><br>/dennis<br><br><br>