2
현재 웹 사이트 용 메시징 시스템을 개발하고 있습니다.메시지에서 참조와 숨은 참조를 구분하는 방법은 무엇입니까?
지금까지이 같은 파일보기 :
/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
/응용 프로그램/모델 /chat.rb
has_many :user_chats
has_many :users, :through => :user_chats
has_many :messages
이제는 @ chat.users를 통해 채팅에 참여하는 모든 사용자
하지만 두 그룹의 사용자를 어떻게 구분할 수 있습니까? 수신자와 숨은 참조 수신자에게 전달합니다.
user_chat 모델에 bbc : boolean을 추가하는 방법에 대해 생각했습니다. 너희들은 어떻게 생각하니?
좋아, 감사합니다! 방금 주위를 둘러 보았고 또 다른 문제가 발생했습니다. 깃발을 어떻게 세웠습니까? 현재'conversation.user_ids = ids'를 통해 대화에 사용자를 추가하고 있습니다. 'ids'는 사용자 ID 배열입니다. – Cojones
추가 정보. –
Btw는 Ruby 1.9 해시 구문을 사용하려고합니다. 'has_many : bbc_users, through : : user_chats, conditions : {bbc : true} ' –