Question

I have problem with kaminari gem. I have forum controller. On forum controller show action.View for show action is table with all topics associated with this forum. It looks like this:

 class ForumsController < ApplicationController
  before_action :authenticate_user!
  before_action :set_forum, only: :show
  def index
    @forums = Forum.all
  end

  def show
   @forum_topics =  @forum.topics.page(params[:page])
  end

  private
  def set_forum
    @forum = Forum.find(params[:id])
  end
end

Forum show view:

= paginate @forum_topics

At the bottom of the page I see pagination links but when i click to take to the second page i have the same topics like in the first page? What's wrong? Any ideas?

Était-ce utile?

La solution

Seems that the pagination links don't use the same name parameter like the one your controller expects:

params[:page]

Make sure that the urls generated on the pagination links have something like page=2

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top