alphagov/whitehall — comment on commit 57b2fdb5780aca5b572862e414e945ee7d1f6a5a
File:  line 0
By tomafro:

Defining the relationship on `Document` rather than `Topic` means neither `Document` or `Topic` need to know about the different types of document (speeches, policies, publications, consultations, etc):

class Topic
has_many :policies, through: document_topics, class_name: "Policy", source: :document
has_many :news_articles, through: document_topics, class_name: "NewsArticle", source: :document
has_many :consultations, through: document_topics, class_name: "Consultation", source: :document
has_many :speeches, through: document_topics, class_name: "Speech", source: :document
has_many :publications, through: document_topics, class_name: "Publication", source: :document
end

The second reason is that scopes like `in_topic` can be chained with other scopes like `in_organisation` to further narrow the list of documents returned.