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.
searches_create_path
via POST request. – Leatherback