I’m currently trying to develop a messaging system for my website.
So far the file look like this:
/app/models/user.rb
has_many :user_chats
has_many :chats, :through => :user_chats
has_many :messages, :through => :chats
/app/models/user_chat.rb
belongs_to :user
belongs_to :chat
has_many :messages, :through => :chats
/app/models/chat.rb
has_many :user_chats
has_many :users, :through => :user_chats
has_many :messages
So now I can get all users participating in a chat via @chat.users
But how can I separate two groups of users? to recipients and bcc recipients.
I thought about adding a bbc:boolean to the user_chat model. What do you guys think?
I would too add a boolean
bccflag to yourUserChatmodel, that is one of the advantages using has_many_through associations over has_and_belongs_to_many.Removed invalid answer