我搜索了很久,但仍然无法解决我的问题。这是我的控制器:
def show
@topic = Topic.find(params[:id])
@topic.posts = @topic.posts.page(params[:page]).per(2) # 2 for debugging
end
那个功能运行良好,因为主题视图被缩减为两篇帖子。但是,当我将它添加到 show.html.erb 中时:
<%= paginate @topic.posts %>
我遇到了这个错误:
undefined method `current_page' for #<ActiveRecord::Relation:0x69041c9b2d58>