I can’t speak for the OP, but in my case I needed something like:
class Report < ActiveRecord::Base has_many :reports_subjects has_many :subjects, through: :reports_subjects, class_name: ->(report) { report.subjects_type }
def subjects_type # divine required subject model class somehow end end
Of course, that won’t fly since the class_name is evaluated purely as a string deep down in the reflection and at that point, all knowledge of the specific instances involved in an association has been discarded.