This project is archived and is in readonly mode.

#5168 ✓invalid
Tatsuya Ono

has_one through doesn't work on new record

Reported by Tatsuya Ono | July 21st, 2010 @ 09:27 AM

Here is example:

class Organization < ActiveRecord::Base
  has_many :members
end
class Member < ActiveRecord::Base
  has_one :organization # or belongs_to
end
class MemberHouse < ActiveRecord::Base
  has_one :member # or belongs_to
  has_one :organization, :through => :member
end

Then...

@organization = Organization.last
@member = @organiation.members.last

@member_house = MemberHouse.new(:address => "87 Worship Street")
@member_house.member = @member

In this situation, I expect that @member_house.organization returns @organization; but it returns nil actually.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Tags

Pages