我正在使用邮箱程序gem与我的rails应用程序,我想订购我的收件箱消息,以便当用户收到一条新消息时,我想要通知或跟踪哪些消息已被读取,哪些没有和没有订购消息在页面顶部具有未读/新消息.
这是我的对话控制器
class ConversationsController < ApplicationController before_action :get_mailBox before_action :get_conversation,except: [:index] def index @unread_messages = @mailBox.inBox(unread: true).count @conversations = @mailBox.inBox({page: params[:page],per_page: 10}) end private def get_conversation @conversation ||= @mailBox.conversations.find(params[:id]) end def get_mailBox @mailBox ||= current_user.mailBox end end
我试图通过以下方式订购邮件:
@conversations = @mailBox.inBox({page: params[:page],per_page: 10}).joins(:receipts).select("mailBoxer_conversations.*,mailBoxer_receipts.*").order('mailBoxer_receipts.is_read')
但它没有奏效.
请建议一个解决方案.