I have 3 tables named
Users table,
Messages Table and the
Message_users Table
and the Users table will be be used to store users’ info while the Messages table will be used to store the messages’ sent by users and the Message_users table will store the the message_id and the sender_id(the user who sent the message) and the receiver_id(the user to receive the message)
In the model class of Message, I have this
class Message < ApplicationRecord has_many :user, :through :message_user dependent: :destroy end
and in the User model, I have this
class User < ApplicationRecord has_many :messages, :through :message_user, dependent: :destroy end
I don’t know if this is the correct way to create the linkage between the Message model and the User model