I''ve just recently started learning rails, and everything is going well
for my find(:all) situations. I''m now trying to do limited find, vis:
def bug_table
@Bug_list = Bug.find(:all,
:conditions => [ "bug_status NOT LIKE
''CLOSED'' and
bug_status NOT LIKE ''VERIFIED''" ]
)
@bug_pages, @bugs = paginate @Bug_list, :per_page => 25,
<-- line 22
:order_by => ''priority, bug_severity, bug_id''
render :action => ''list''
end
and I get
"#<Bug:0x25a4be0>#<Bug:0x25a48d4>[a gazillion other bug
objects, snip]"
is not a valid constant name!
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?
Thanks!
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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''"
?
Fred
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> 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? Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Olie D. wrote:> 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---