Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:08:14+00:00 2026-06-15T11:08:14+00:00

I have a small Rails app built for me by a developer, and the

  • 0

I have a small Rails app built for me by a developer, and the code has lots of anomalies that I’m trying to correct. I am battling a strange problem with will_paginate giving me the following error:

The @home variable appears to be empty. Did you forget to pass the collection object for will_paginate?`

I’ve googled the error message, but have not found anything useful in solving this problem, so I turn to you, stackoverflow.

So my search form to find a location looks like this:

<%= form_for :search_place, :url => search_results_home_index_path, :html => {:class=>""} do |f| %>
  <%= f.hidden_field :search_type, :value=>2 %>
  <%= f.text_field :city,{:placeholder => "Town", :class=>"input-small"} %>
  <%= f.text_field :county,{:placeholder => "County", :class=>"input-medium"} %>
  <%= f.select(:country, db_countries.map(&:country), {:include_blank => 'Select a Country'}, :class=>"input-medium") %>
<%end%>

Which references home_controller.rb as such:

def search_results
  :
  elsif !params[:search_place].blank?
    session[:search_params] = params[:search_place]
    @documents = Location.search_location(params[:search_place], params[:page])
  end

And picks up the collection from the Location model location.rb

def self.search_location(search_params,page,per_page=50)
  condition_str  = ""
  condition_str += "(UPPER(locations.town) like '%#{search_params[:city].upcase}%' OR UPPER(locations.town) like '%#{search_params[:city].upcase}%') AND " unless search_params[:city].blank?
  condition_str += "(UPPER(locations.county) like '%#{search_params[:county].upcase}%' OR UPPER(locations.county) like '%#{search_params[:county].upcase}%') AND " unless search_params[:county].blank?
  condition_str += "(UPPER(locations.country) like '%#{search_params[:country].upcase}%' OR UPPER(locations.country) like '%#{search_params[:country].upcase}%') " unless search_params[:country].blank?

  unless condition_str.blank?
    self.where(condition_str).paginate(:per_page=>per_page,:page=>page)
  else
    self.where("1=0").paginate(:per_page=>1,:page=>page)
  end

end

The search results are displayed in a search results table as follows:

<%= render "documents/document_common_list"%> 
<%= will_paginate @documents, :renderer => BootstrapLinkRenderer %>

So this pulls out the correct search results and displays the correct first page and the paging block, but crashes with the above error (about @home) if I try to access other pages.

will_paginate works perfectly elsewhere on the site in this way, except the collection is built in the controller rather than the model so this may be the problem (I’m not entirely sure which is the correct way to do this, but I’m working with someone else’s code so struggling a bit).

Would be very grateful for any pointers to move me in the right direction

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:08:15+00:00Added an answer on June 15, 2026 at 11:08 am

    I’m not entirely sure about this, but I think the problem you have is described here:

    https://github.com/mislav/will_paginate/wiki/Simple-search

    Basically, you need to change the http method on your form to GET (by inserting “:method => ‘get'” in you form tag) , so that it doesn’t lose your parameters when you view later pages of search results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small Rails 3.2.1 app that uses CarrierWave 0.5.8 for file uploads
I have a small rails app on Heroku that pulls in my client's latest
I have a small rails app that is using acts_as_list to implement drag and
In a rails 3.0 app that uses jquery mobile for mobile devices I have
I have a small rails app I got all gung-ho on tonight wanting to
I'm trying to import a CSV file to my Rails app that's using CarrierWave
Currently I have a Rails 2.3 app that is a CMS serving over 100
I have a Rails app that processes a large (millions) number of records in
I have written a small rails app to serve up content to another site
I have a small Rails 3 app (you have a listing with photos, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.