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

  • SEARCH
  • Home
  • 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 7703883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:33:37+00:00 2026-05-31T23:33:37+00:00

I have been using solr search and now I am adding pagination via the

  • 0

I have been using solr search and now I am adding pagination via the will_paginate gem. Loading the initial page works with the pagination links on the bottom of the webpage rendering correctly and working fine, but when I do a search via Solr the pagination links do not get updated. It always loads the 155 pagination links for the non-search compared to at most the 2 pagination link for a search. They retain the old links from the initial page load.

books.rb:

  def self.search(query,page)
    search = Sunspot.search(Book) do
      keywords query
      paginate :page => page, :per_page => 10
    end
    search.results
  end

books_controller.rb:

  def index
    if params[:query] && !params[:query].blank?
      @books = Book.search(params[:query],:page => params[:page])
    else
      @books = Book.order_by(:title).paginate(:page => params[:page], :per_page => 10)
    end
  end

index.html.erb:

  <%= form_tag books_path, :method => :get, :remote => true, :id => "book_search" do  %>
    <div><%= label_tag :query, "Search" %> <%= text_field_tag "query", "" %></div>
    <div><%= submit_tag "Find", :class => "" %></div>
  <% end %>
  <div><%= will_paginate @books %></div>

I have both the will_paginate and sunspot gems installed.

Thanks

  • 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-05-31T23:33:38+00:00Added an answer on May 31, 2026 at 11:33 pm

    First of all, you can shorten the line

    if params[:query] && !params[:query].blank?
    

    into just

    if params[:query].present?
    

    as it will accomplish the same thing.

    Are you sure you are hitting the correct code branch and not running the Book.order_by line? and are you sure you are testing it with different values of the page parameter?

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

Sidebar

Related Questions

I have been using C# for a while now, and going back to C++
I have been using Ruby for a while now and I find, for bigger
I have been using IoC for a little while now and I am curious
I have been using the CSLA framework for couple of years now for windows
I have been using json.NET successfully in projects for some time now without any
I have been using these files all day... And then suddenly this is now
I have been using SolrJ, the Java client for Apache Solr server, at my
We have been using SVN at my workplace for a few years now and
I have been using JIRA for the past 15 months, and now I find
I have been working on making a Search using Solrnet which is working the

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.