Is there a cleaner way of associating a has_one...through relationship if the original object can have one and only one relationship through a couple of different objects (i.e. in the example below, they will only have 1 job but it may be through any of the available options)?
Toy example:
class Person
belongs_to :employer
belongs_to :consulting_agency
belongs_to :temp_agency
has_one :job, through: :employer
has_one :job, through: :consulting_agency
has_one :job, through: :temp_agency
Can this be consolidated or cleaned up in any way?
jobrelationship that would exist is thehas_one :job, through: :temp_agencybecause this will overwrite thethrough: :consulting_agencywhich will have overwritten thethrough: :employerhas_ones and create ajob_lookup-type of method? This would forego the implied associations.def job; self.employer&.job || self.consulting_agency&.job || self.temp_agency&.job; endJobbelong to one of those parties (maybe as a polymorph) and then have thePersonhavehas_one :jobandhas_one :employer, through: :job