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 6598619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:22:25+00:00 2026-05-25T18:22:25+00:00

I have a page which is used for searching through listings by submitting data

  • 0

I have a page which is used for searching through listings by submitting data using the supplied forms. The form parameters are submitted via ajax (post request), a new record is created in the searches table and then the listings are displayed (dynamically, on the same page the form is submitted from) via the show action for this record.

The results have pagination links provided by kaminari like so:

<%= paginate matches, 
  :params => {:controller => 'searches',
  # I have to specify the id because my searches are stored in the database
  :action => 'show', :id => search.id},
  :remote => true %>

Note that the pagination links are dynamically included to the page. So, when I do new search and get new listings, the server re-renders the pagination links.

Here is my show action in the searches controller

def show
  @search = Search.includes(:rate).find(params[:id])
  @matches = @search.matches.order(sort_column + " " + sort_direction).page(params[:page])

  respond_to do |format|
    format.html
    format.xml { render :xml => @matches }
    format.js
  end
end

For some reason I can’t figure out, all of the parameters I use in the search forms (and there’s a lot of them) are being attached to the kaminari pagination urls giving me hrefs like this:

<a href="/searches/145?massive parameter list omitted" data-remote="true" rel="next">2</a>

The omitted parameter list is so long that it’s too large to be a valid GET request and I get a 414 error code.

As you can see from the searches -> show action I have above, it’s unnecessary for the pagination links to have all this info appended. All they need is the route, id and page number.

How do I prevent this from happening?

By the way, I’ve tried setting :method => :post in the kaminari options. Doesn’t seem to help. I’m using kaminari v 0.12.4 (latest) and Rails 3.1.rc4.

  • 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-25T18:22:26+00:00Added an answer on May 25, 2026 at 6:22 pm

    General Idea

    You can fix this by editing the pagination partials to manually strip out the params from the url, then add the page param back. I know this is a hack, but it seems like the quickest way to fix this issue if pagination is broken (as it was for me).

    I’m expanding this from the solution posted in the GitHub bug report for this issue.

    You have to edit each of the 5 pagination link partials: _page.html.erb (by number), _first_page.html.erb and _last_page.html.erb, _prev_page.html.erb and _next_page.html.erb.

    You can find the page number you want from the local variables made available in the partials: current_page, page, num_pages.

    Specific Instructions

    If you haven’t already, generate the pagination partials in your app by running rails g kaminari:views default

    Then edit the partials as follows:

    #_page.html.erb
    <%
     unless page.current?
       url = url.split('?')[0] + '?page=' + page.to_s
     end
    %>
    
    <span class="page<%= ' current' if page.current? %>">
      <%= link_to_unless page.current?, page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
    </span>
    
    # _first_page.html.erb
    <span class="first">
      <% url = url.split('?')[0] + '?page=1' %>
      <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
    </span>
    
    # _prev_page.html.erb
    <span class="prev">
      <% url = url.split('?')[0] + '?page=' + (current_page.to_i - 1).to_s %>
      <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
    </span>
    
    # _next_page.html.erb
    <span class="next">
      <% url = url.split('?')[0] + '?page=' + (current_page.to_i + 1).to_s %>
      <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
    </span>
    
    # _last_page.html.erb
    <span class="last">
      <% url = url.split('?')[0] + '?page=' + num_pages.to_s %>
      <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
    </span>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page, used for admin purposes, which runs a task (image
I have a page which displays ~300 pages worth of tabular data. Firefox, Chrome,
I have a form in a jsp file, which I have used to get
I have page register.php, which is used to get user informations, after completion of
I have several asp:panels on a webform page which is used together with an
I have a ListView control which I used to populate using an ASP ObjectDataSource
I have a page which submits a form on page load and redirects the
I have a basic page which is used in an iFrame on an intranet
I have page which is redirected from htaccess. now I can pass the German
I have a page which spawns a popup browser window. I have a JavaScript

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.