How can I make a POST call instead of GET call with will_paginate?


How can I make a post call instead of get call when i am paginating through pages using rails gem will_paginate?

In controller I have

@bills = Bill.where(some_condition) # returns collection @bills = @bills.paginate(:page => params[:page], :per_page => 5)

In view have used a table structure and at the end, have used <%will_paginate%>, hence page 1 is showing up, but when I click on "next" or "page 2" then GET req. goes, I want to change it to POST call, is it possible?


I agree with antiqe's comment it's not right to paginate through POST request.

But if you have made up your mind to use POST read below:


By modifying the will_paginate

Source enchante's comment


use will_paginate doesn't support post by default, if you insist to use post, you need to customize LinkRender for will_paginate, see reference: github.com/mislav/will_paginate/wiki/Link-renderer

</blockquote></li> <li>

By custom POST requests

From the <a href="https://groups.google.com/forum/#!topic/will_paginate/S_F46cTpGT8" rel="nofollow">source</a>:


the only correct way to do pagination in HTML would be to render a form inside which each pagination link is a submit button with the attribute name="page" set to page number as value. This form should also preserve existing search parameters, therefore it should have a hidden field for each of the current parameters. Clicking on the submit button will resubmit the advanced search with the page parameter changed.

</blockquote></li> <li>

By custom ajax request

Or You can write a javascript to prevent the default get request on pagination links and send ajac post request instead. see more <a href="https://stackoverflow.com/questions/15568179/does-will-pagination-work-with-forms-which-have-method-post" rel="nofollow">here</a>

</li> </ol>

The reason will_paginate don't support POST is that nobody uses it.


That's possible. But not suggest to do so.

@bills = @bills.paginate(:page => params[:page], :per_page => 5)

Here the <em>params[:page]</em> controls which page should be shown, include <em>:page</em> parameter in the post, that should work.


will_paginate doesn't support post by default, if you insist to use post, you need to customize LinkRender for will_paginate, see reference: github.com/mislav/will_paginate/wiki/Link-renderer


  • Double plus sign for the last line in git-diff of merge
  • Java EE 6 Login module
  • How do I revert sys.stdout.close()?
  • Type mismatch: cannot convert from ListFragment to Fragment
  • Global session variable in express.js route?
  • parsing xml and html page with lxml and requests package in python
  • css font-size and line-height not matching the baseline
  • replacing while loop with list comprehension
  • CSS Grid, position absolute an element in a css grid item: IMPOSSIBLE
  • Express JS Display Data By ID
  • Certain Arabic text gets incorrectly shown while other Arabic text gets showed normally?
  • CORS with socket.io
  • How to implement Deep Linking in Roku SG application?
  • DIV instruction jumping to random location?
  • Cannot upload to OneDrive using the new SDK
  • Custom Tabgroup Appcelerator
  • ActiveRecord query for a count of new users by day
  • $wpdb not working in file of WordPress plugin
  • Get data from AJAX - How to
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Symfony2: How to get request parameter
  • How to limit post in wp_query
  • jquery mobile loadPage not working
  • Arrays break string types in Julia
  • Data Validation Drop Down Box Arrow Disappearing
  • InvalidAuthenticityToken between subdomains when logging in with Rails app
  • SQL merge duplicate rows and join values that are different
  • AngularJs get employee from factory
  • log4net write single file for each call to log.info
  • Free memory of cv::Mat loaded using FileStorage API
  • Getting error when using KSoap library to consume .NET web services
  • How do you join a server to an Active Directory (domain)?
  • Memory offsets in inline assembly
  • Turn off referential integrity in Derby? is it possible?
  • LevelDB C iterator
  • Can't mass-assign protected attributes when import data from csv file
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize