如何使用邮箱访问已发送邮件页面上的收件人 [英] How to access recipient on sent messages page with mailboxer

查看:180
本文介绍了如何使用邮箱访问已发送邮件页面上的收件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用邮箱管理器gem在Rails应用程序中的红宝石中发送消息.宝石在工作.我一辈子都想不通如何在已发送邮件页面上访问收件人.在已发送消息"页面上,我试图遍历已发送消息,并访问已发送消息的收件人并将该人显示给用户.

I am using the mailboxer gem to send messages within my ruby on rails app. The gem is working. I can't for the life of me figure out how to access the recipient on the sent messages page. On the sent messages page, I am trying to loop through sent messages, and access the recipient of the sent messages and display that person to the user.

在常规收件箱页面上,我使用了以下内容:

On the regular inbox page, I used the following:

<% all_mail = current_user.mailbox.inbox %>
<% all_mail.each do |letter| %>
    <tr>
        <td><%= letter.messages.last.sender.email %></td>
        <td><%= letter.messages.last.subject %></td>
   </tr>
<% end %>

我正在尝试对已发送的邮件页面进行类似的外观,但是我不知道该怎么做(特别是访问收件人的电子邮件).

I am trying to make a similar look for the sent messages page, but I can't figure out how to do it(specifically access the email of the recipient).

我不能使用:

#user wants to retrieve all his conversations
user.mailbox.conversations

#user wants to retrieve his inbox
user.mailbox.inbox

#user wants to retrieve his sent conversations
user.mailbox.sentbox

因为无法组织使用这些方法显示消息的方式(至少据我所知).如何遍历邮件并查找每封邮件的收件人?

because there is no way to organize how the messages are displayed using those methods (at least as far as I know). How can I loop through the messages and find the message recipient for each message?

推荐答案

您在对话中有参与者(您称其为字母).

You have the participants in conversations (you call it letters).

只需过滤当前用户,您就会好起来.

Just filter the current user and you'll be good.

conversation = user.mailbox.sentbox.first
filtered_participants = conversation.participants.reject do |u| 
  u.id == current_user.id
end

这篇关于如何使用邮箱访问已发送邮件页面上的收件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆