Acts_as_ferret and will_paginate

hi!

I have been trying to use will_paginate with acts_as_ferret and it works
correctly in the first page, but nowhere else. When I try to see the
second or any other page I get a nil object error while evaluating
nil.each.

this is in the controller:

def search_results
if request.post?
@profiles = Profile.find_with_ferret params[:query], :page
=>params[:page], :per_page => 9

end

and in my view search_results.rhtml I have this:

<%= render(:partial => “shared/sidebar”) %>

<% for profile in @profiles %> <%= link_to profile.name, :controller=>'dogprofile', :action =>'show', :id=>profile %> <%end%> <%= will_paginate @profiles %>

As I said the first results page is ok, somehow It deletes the result
collection when tries to access to another page.

any idea please?

thanks!

Javi J. wrote:

hi!

I have been trying to use will_paginate with acts_as_ferret and it works
correctly in the first page, but nowhere else. When I try to see the
second or any other page I get a nil object error while evaluating
nil.each.

this is in the controller:

def search_results
if request.post?
@profiles = Profile.find_with_ferret params[:query], :page
=>params[:page], :per_page => 9

end

You need to make sure your search results are present in subsequent
pages. I usually do something like this:

if !params[:search_string].nil?
@search_string = params[:search_string].downcase
session[:search_string] = @search_string
else
@search_string = session[:search_string]
end

There’s probably a better way to do this, but that’s what I do.