Has_one through with new record


#1

I need to set a has_one through association to an unsaved record. In
my code


class JobPositionPosting < ActiveRecord::Base
has_one :job_position_posting_hiring_org
has_one :hiring_org, :through => :job_position_posting_hiring_org
end

class JobPositionPostingHiringOrg < ActiveRecord::Base
belongs_to :job_position_posting
belongs_to :hiring_org
end

class HiringOrg < ActiveRecord::Base
has_many :job_position_posting_hiring_org
has_many :job_position_posting, :through
=> :job_position_posting_hiring_org
end

job_position_posting = JobPositionPosting.new
hiring_org = HiringOrg.new

job_position_posting.hiring_org = hiring_org

, job_position_posting.hiring_org is always set to nil. If i save
job_position_posting and hiring_org everything works fine. How can i
realize an has_one :trough with new records?