多対多の関係を持つ 2 つのエンティティがあります。ユーザー:
class User < ActiveRecord::Base
has_and_belongs_to_many :conversations
end
そして会話
class Conversation < ActiveRecord::Base
has_and_belongs_to_many :users
多数のユーザーがいますが、このユーザー間の会話を選択するにはどうすればよいですか?
現在find_by_sql
、JOIN 演算子を使用した大規模な SQL クエリを使用していますが、これは良いアプローチではないと思います。