如何订购邮箱收件箱?

Sac*_*ngh 14 ruby ruby-on-rails ruby-on-rails-4 mailboxer

我在mailboxer我的rails应用程序中使用gem,并且我想订购我的收件箱消息,以便当用户收到新消息时,我想要通知或跟踪哪些消息已被读取,哪些消息未被读取并订购消息,以在页面顶部显示未读/新消息.

这是我的对话控制器

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
Run Code Online (Sandbox Code Playgroud)

我试图通过以下方式订购邮件:

@conversations = @mailbox.inbox({page: params[:page], per_page: 10}).joins(:receipts).select("mailboxer_conversations.*, mailboxer_receipts.*").order('mailboxer_receipts.is_read')
Run Code Online (Sandbox Code Playgroud)

但它没有奏效.

请提出解决方案.

Nic*_*rer 0

好的 - 所以浏览这里的文档就是我所得到的。

#is_read在其他地方为您工作过吗?我可以找到的方法和属性是#mark_as_readreceipt.is_unread?;你有没有尝试过组织is_unread或尝试在控制台中对此进行一些调试?

以下是我正在挖掘的资源:

  1. http://www.rubydoc.info/gems/mailboxer/frames

  2. 无法弄清楚如何更新邮箱程序 is_read