2017-04-12 36 views
-1

在Rails上,我收到錯誤「...,你忘了傳遞will_paginate的集合對象嗎?」我沿着使用will_paginate gem是用mailboxer你忘了傳遞will_paginate的集合對象嗎? Rails

視圖/對話

<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

請閱讀「[問]」和「[mcve]」及其鏈接頁面。你沒有提出問題,也沒有顯示錯誤或如何運行你的代碼。請檢查編輯和格式化文本的幫助,並使其可讀。 –

回答

1

<%= will_paginate @conversations%> 檢查您需要傳遞變量,您要分頁。