Given the following classes:
class Candidate
has_many :applications
has_many :companies, :through => :job_offers
end
class JobOffer
belongs_to :company
this is how I will structure the models:
class Candidate
has_many :applicatons
has_many :job_offers
has_many :offering_companies, :through => :job_offers
end
class Application
belongs_to :candidate
end
class JobOffer
belongs_to :candidate
belongs_to :company
validates_uniqueness_of :candidate_id, :scope => :company_id
end
class Company
end
This should work! Btw. I will call the application something else to avoid the naming confusion( rails already has application.rb