I'm having trouble paginating a topic's posts with Kaminari. The paginator partial shows up and seems to be calculating the number of pages it should have correctly, but all of the topic's posts are displayed on each page instead of the 2 posts I'm trying to get.
I have Topic and Post models, controllers, and views. A topic has_many posts, and a post belongs_to a topic.
I'm running Rails 4.
controllers/topics_controller
class TopicsController < ApplicationController
[snip]
def show
# Paginate
@topic = Topic.find(params[:id])
@posts = @topic.posts.page(params[:page]).per(2)
end
[snip]
end
views/topics/show.html.erb
[snip other renders for header, breadcrumbs, etc.]
<%= render 'panel', :topic => @topic %>
[snip other renders]
views/topics/_panel.erb
<%= paginate @posts%>
[snip containing divs]
<h2><%= link_to topic.title, category_path(topic.id) %></h2>
<%= topic.description %>
[snip containing divs]
<%= render 'posts/posts', :topic => topic %>
posts/_posts.erb
<% for post in @topic.posts %>
[snip table of post information]
<% end %>