Railsアプリケーションでgemを使用mailboxer
しています。ユーザーが新しいメッセージを受信したときに通知を受け取るか、どのメッセージが読まれたか、どのメッセージが読まれていないかを追跡して、ページの上部に未読/新しいメッセージを表示するメッセージ。
これが私の会話コントローラーです
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')
しかし、うまくいきませんでした。
解決策を提案してください。