Search code examples
ruby-on-railstwitter-bootstrappaginationkaminari

Paginate link with hash parameter with kaminari


I am using kaminari to paginate the results in my view. The url is /tracks and I use this code in the view to create the pagination:

<%= paginate @tracks %>

The problem is that the paginated content is inside a bootstrap tab, witch is activated when the user accesses the link with the hash parameter:

/tracks#items

Is there any way to have the pagination link be something like:

/tracks?page=X#items

so the tab is automatically enabled when the user clicks the page link?


Solution

  • You can add the anchor to the pagination links like this:

    <%= paginate @tracks, :params => { :anchor => 'items' } %>