If you don’t get a suitable answer here, you should know that there is
a will_paginate Google Group, just like this rubyonrails-talk group.
Naturally, it’s called “will_paginate”.
where @filters is a hash like {:hidden => false, :category_id => 5}.
I notice that you don’t have an :all or :first at the beginning.
Maybe this matters.
Yes you can do conditional paginates. See my search method below.
Note that you have to remember the search conditions between pages
because you have to restate them on calls for subsequent pages. I stick
mine in the session.
Hope this helps,
John
def full_search
unless params[:page]
session[:search] = [“category_id = ? and address_posttown like ?
and address_postcode like ? and published is true”,
params[:item][:category_id],
(params[:item][:address_posttown].to_s) +"%",
(params[:item][:address_postcode].to_s) +"%"]
end
@items = Item.paginate :page => params[:page],
:conditions => session[:search]
if @items.empty?
flash.now[:error] = "Sorry, nothing matched your search request"
end
# old-fashioned reload for browsers not doing AJAX
render :action => :search unless request.xhr?
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.