ActiveRecord query to return related Documents using RelatedDocuments join table
问题 In my app, users can collect favorite Documents . I want to return a list of documents most relevant to those they have favorited, using a related_documents join table that has a relevance_score:integer for the relationship between a document and a related document. TLDR; see the update at the bottom for an almost-working query. Without success, I have tried various queries like: some_user.favorited_documents.joins(:related_to_documents) .select("docid_id FROM documents.related_documents")