ruby-on-railsruby-on-rails-3kaminari

Is it possible to add an anchor/param to links with Kaminari?


I'm using pagination with Kaminari. It's working awesome.

One thing that I want for now is, adding #comment_section behind the url that Kaminari generates.

For example, my views is just like this. I'd like it to goes to the top of this section when page is loaded by clicking the link that Kaminari generated.

Is it possible?

<a name="comment_section">
<span id="comment">
 <%= render 'users/comment' %>
</span>
<%= paginate @comments, :window => 4 %>

Solution

  • From the Kaminari documentation:

    <%= paginate @users, params: { controller: 'foo', action: 'bar'} %>
    

    So I guess you can modify it to have an anchor param, in your case:

    <%= paginate @users, params: { anchor: 'comment_section' } %>
    

    Hope this helps!