Search code examples
ruby-on-railsrubyruby-on-rails-4messagingmailboxer

mailboxer gem - find message sender


I am having the hardest time with the mailboxes gem. I have gotten it working in that I can send and receive messages, but for the life of me I cannot figure out how to display them. i want to display the inbox in table organized like this:

message sender | message subject | message sent date

I have been working for hours to try and figure out how to access the sender of the message in the receivers inbox, but I can't figure it out. I've tried looping through conversations, receipts, notifications, etc and I still cannot figure out what to do. I can't use:

#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 sender for each message?


Solution

  • A Mailboxer::Message is a Mailboxer::Notification

    And you can have the notification's sender: message.sender

    A Mailboxer::Conversation is a collection of messages.

    You can get the participants, even the originator (plus many other) from it.

    Is it clearer?