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? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Fri, Oct 22, 2010 at 01:37:43AM -0700, Alexey Ilyichev wrote:> 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. -- Aaron Patterson http://tenderlovemaking.com/
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 On 22 окт, 21:08, Aaron Patterson <aa...@tenderlovemaking.com> wrote:> On Fri, Oct 22, 2010 at 01:37:43AM -0700, Alexey Ilyichev wrote: > > 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_rec... > > 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. > > -- > Aaron Pattersonhttp://tenderlovemaking.com/ > > application_pgp-signature_part > < 1KбПросмотретьЗагрузить-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
So, is anybody going to do something with that? :-) On 25 окт, 15:47, Alexey Ilyichev <bluesman.a...@gmail.com> wrote:> 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-th... > > On 22 окт, 21:08, Aaron Patterson <aa...@tenderlovemaking.com> wrote: > > > On Fri, Oct 22, 2010 at 01:37:43AM -0700, Alexey Ilyichev wrote: > > > 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_rec... > > > 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. > > > -- > > Aaron Pattersonhttp://tenderlovemaking.com/ > > > application_pgp-signature_part > > < 1KбПросмотретьЗагрузить-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Sat, Nov 06, 2010 at 07:10:36AM -0700, Alexey Ilyichev wrote:> So, is anybody going to do something with that? :-)I will get to it. I have a lot on my plate, but it will happen. :-) -- Aaron Patterson http://tenderlovemaking.com/