在Rails上,我收到错误“......,你忘了传递will_paginate的集合对象吗?”我正在使用will_paginate gem和mailboxer
查看/会话
<p><%= link_to 'Start conversation', new_message_path, class: 'btn btn-lg btn-primary' %></p>
<ul class="list-group">
<%= render partial: 'conversations/conversation', collection: @conversations %>
</ul>
<%= will_paginate %>
控制器/会话
class ConversationsController < ApplicationController
before_action :authenticate_member!
#before_action :get_mailbox
before_action :get_conversation, except: [:index]
def show
end
private
def get_conversation
@conversation ||= @mailbox.conversations.find(params[:id])
end
def index
# @conversations = Conversation.paginate(page: params[:page]) # paginated
@conversations = Conversation.paginate(:page => params[:page], :per_page => 2)
end
end
我该如何解决这个问题?
答案 0 :(得分:1)
&lt;%= will_paginate @conversations%&gt; 检查一下你需要传递变量,你想要分页。