Tag: 私信消息

在Rails中的Mailboxer收件箱中显示用户名

我在我的Rails应用程序中使用Mailboxer( https://github.com/ging/mailboxer )gem来处理用户之间的私人消息。 根据文档,我使用= render mailbox.inbox来显示登录用户的所有对话(消息)列表。 但是,该方法仅输出消息的主题。 我需要显示消息的发件人以及主题。 如何编辑此输出以显示发件人姓名? SQL表显示发件人名称未存储在会话表中,而是存储在notification_on_conversation_id(一对多)的通知表中。 我尝试使用但是我收到以下错误: NoMethodError in Conversations#index undefined method `notifications’ for nil:NilClass 我可以将哪些内容添加到会话控制器和视图中以显示会话的用户和主题? 谢谢! 对话控制器: class ConversationsController < ApplicationController before_filter :authenticate_user! helper_method :mailbox, :conversation def create recipient_emails = conversation_params(:recipients).split(',') recipients = User.where(email: recipient_emails).all conversation = current_user. send_message(recipients, *conversation_params(:body, :subject)).conversation redirect_to conversation end def reply current_user.reply_to_conversation(conversation, *message_params(:body, :subject)) redirect_to […]