has_one :through issue

Hi.

I'd like to hear your opinions about the following issue.

I set up associations like this:
class User
  has_one :user_info
  has_many :bank_infos
end

class UserInfo
  belongs_to :user
end

class BankInfo
  belongs_to :user
  has_one :user_info, :through => :user
end

Then given a user with user_info present I build a bank_info:
bank_info = user.bank_infos.build

and I expect bank_info.user_info to equal bank_info.user.user_info,
however I get nil. The reason I get nil is the condition for loading
associated object in method load_target:
http://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/association_proxy.rb#L223
in line 236

Do you think its reasonable to make bank_info.user_info to load the
associated object in the case described above?

It seems reasonable to me. Can you file a ticket in lighthouse and
assign it to me?

Thanks.

I have created a ticket on lighthouse before, and even assigned a
patch. Well, I'm not sure if this patch is correct, or it should work
some other way. Take a look please:
https://rails.lighthouseapp.com/projects/8994/tickets/5854-has_one-through-on-new-record-doesnt-query-for-associated-object

So, is anybody going to do something with that? :slight_smile:

I will get to it. I have a lot on my plate, but it will happen. :slight_smile: