paginate query all the records, why?

5 views
Skip to first unread message

itoge

unread,
Dec 3, 2009, 7:41:52 PM12/3/09
to Searchlogic
Using will_paginate and searchlogic gems.

When

@search = GradeList.search(params[:search])
@grade_lists = @search.all.paginate(:page => params[:page])

In my view:
- @grade_lists.each do |grade_list|
= grade_list.evaluation_period.name

The result in the view is correct only the first 30 records are
displayed

But in the log there is no LIMIT clause:
GradeList Load (12.8ms) SELECT * FROM "grade_lists"

Why? Is it querying all the records?

If I change to:
@grade_lists = GradeList.paginate(:page => params[:page])

In the log there is a LIMIT clause:
GradeList Load (9.1ms) SELECT * FROM "grade_lists" LIMIT 30 OFFSET
0


ricsrock

unread,
Dec 16, 2009, 10:31:31 AM12/16/09
to searc...@googlegroups.com
Try:

@grade_lists = @search.paginate(:page => params[:page], :per_page =>
30) # leave off the call to #all and add the :per_page parameter to
your #paginate call.
> --
>
> You received this message because you are subscribed to the Google
> Groups "Searchlogic" group.
> To post to this group, send email to searc...@googlegroups.com.
> To unsubscribe from this group, send email to searchlogic...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/searchlogic?hl=en
> .
>
>

Reply all
Reply to author
Forward
0 new messages