1

We have a chat feature in our rails app where users can talk to each other.

This is done using Actioncable, and a basic messages and inboxes schema structure, where:

  • Each unique conversation between 2 participants has its own inbox_id, and all messages sent by users to another user reside in that inbox_id.
  • In the messages table, which holds the records of every message, we have a read column (which is currently unused).

We want to implement a way for our system to know if messages have been read by a specific user, but we're not entirely sure what the best method to facilitate this might be. We're unsure on how we should go about designing this exactly.

Yeahprettymuch
  • 501
  • 5
  • 16
  • A join table - users -> user_messages -> messages. – max Dec 05 '21 at 09:14
  • I think you can add `read_user_ids` into `messages` table and stores user's id who read into an array. After that you can easily retrieve by [Rails's serialize](https://apidock.com/rails/ActiveRecord/AttributeMethods/Serialization/ClassMethods/serialize) – Danh Mạnh Dec 05 '21 at 16:44

0 Answers0