Unwanted form parameters being appended to pagination links

后端 未结 4 1095
抹茶落季
抹茶落季 2021-02-08 04:29

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 i

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-08 05:19

    Old Post. Better solution.

    If you are using kaminari for pagination for nested resources with ajax updates, you will find Kaminari attempts to build the url based on the current path, regardless of the params you specify, resulting in a routing error.

    The cleanest solution is to use a wildcard route.

    If your paginating comments for a post and have a comments controller with a create and show action, then:

    In your routes:

    match '*path/comments(/:page)' => 'comments#show'
    

    And the pagination widget:

    <%= paginate @comments, params: { controller: :comments }, remote: true %>
    

提交回复
热议问题