The error claims the problem is in
app/controllers/bugs_controller.rb:22:in `bug_table’, which I presume
means lines 22 & 23 (it’s a continued line) – so it doesn’t seem to
want to … what? Does paginate require a “constant”? I thought that
making @Bug_list start with a capital letter would made it a constant.
The probem seems to be more along the line that an array (of
bug-objects) is returned, and I can’t seem to feed those to paginate.
By comparison, this works just fine:
def list
@bug_pages, @bugs = paginate :bugs, :per_page => 25,
:order_by => 'priority, bug_severity, bug_id'
end
Any help or hints about how to do the thing I want in bug_table?
paginate just doesn’t take a collection of objects (and there’s no
reason it should really - you’re half defeating the point of pagination
if what you’re doing is loading all the objects first and then only
displaying 25.
paginate takes the options find does (:conditions, :joins, :order,
:include etc… so why not do
paginate :bugs, :per_page => 25,
:order_by => ‘priority, bug_severity, bug_id’,
:conditions => “bug_status NOT LIKE ‘CLOSED’ and
bug_status NOT LIKE ‘VERIFIED’”
paginate takes the options find does (:conditions, :joins, :order,
:include etc…)
Ah, THAT’S the info I was missing. Works perfectly, thanks!
paginate just doesn’t take a collection of objects (and there’s no
reason it should really - you’re half defeating the point of pagination
if what you’re doing is loading all the objects first and then only
displaying 25.
But I thought paginate DID take a collection as its first parameter.
Ok, I promise not to try to abuse it in the future, but why didn’t it
like my collection? That is: I see the logic-error, but what was the
SYNTAX error?
Also, in the case where I’ve already gathered together an
array/collection/hash/whatever of 1000 of something, and I’d now like to
show them :per_page at a time, is there a decent way to feed them to
paginate? Or is this always an indication that I might want to re-think
my structure, some?
But I thought paginate DID take a collection as its first parameter.
Ok, I promise not to try to abuse it in the future, but why didn’t it
like my collection? That is: I see the logic-error, but what was the
SYNTAX error?
it doesn’t take a collection as its first parameter. It takes a symbol
and (by default) tries to guess a class name from that symbol (eg :bug
=> Bug). That’s blatently not going to work
Also, in the case where I’ve already gathered together an
array/collection/hash/whatever of 1000 of something, and I’d now like to
show them :per_page at a time, is there a decent way to feed them to
paginate? Or is this always an indication that I might want to re-think
my structure, some?
paginate won’t do that. There are other pagination plugins
(will_paginate springs to mind), maybe some of them handle this.
Fred
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.