I am using this gem for private messages: https://github.com/jongilbraith/simple-private-messages
I want to create a thread conversation instead of the e-mail conversation the scaffold have provided.
Example, User A have sent 10 messages to User B. User A have also sent 10 messages to User C.
Instead of looping through all the messages. (e-mail look) I want to create a threat like:
Inbox
Conversation with User A (10 messages)
Conversation with User C (10 messages)
And when clicking on the conversation the messages should be ordered after date. So it would be like a conversation.
The table for messages:
id
sender_id
recipient_id
sender_deleted
recipient_deleted
subject
body
read_at
created_at
updated_at
How do I create these views? How do I group the messages?
Short answer is: you can’t with that gem. You’ll have to extend it and add a Conversation model then bridge that between users and messages.
I propose, instead, you use this gem:
https://github.com/ging/mailboxer
Far more powerful than your current gem, and it comes with conversations out of the box. I’ve used it before to mimic a gmail-like view.
From the guide:
Easy as pie: