Is there any reason why AssociationProxy#reset is def reset @target = nil @loaded = false end rather than def reset @loaded = false @target = nil end The reason I ask is that if you''re reloading a belongs_to association for example and the associated record has vanished then the ActiveRecord::RecordNotFound is rescued and reset is returned. Conceptually I would think that foo.some_association.reload should always give you the current value of the association, i.e. some instance of an ActiveRecord object, or nil if there is none. In this particular edge case what you get back is false instead, which doesn''t seem quite right - nil would be the correct return value. Opinions? Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Is there any reason why AssociationProxy#reset is > > def reset > @target = nil > @loaded = false > end > > rather than > > def reset > @loaded = false > @target = nil > end > > The reason I ask is that if you''re reloading a belongs_to association > for example and the associated record has vanished then the > ActiveRecord::RecordNotFound is rescued and reset is returned. > > Conceptually I would think that foo.some_association.reload should > always give you the current value of the association, i.e. some > instance of an ActiveRecord object, or nil if there is none. In this > particular edge case what you get back is false instead, which doesn''t > seem quite right - nil would be the correct return value. > > Opinions?I can''t see any particular reason for this behaviour, if you can create a patch with tests sounds like a good quick fix. -- Cheers Koz --~--~---------~--~----~------------~-------~--~----~ 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 27 Nov 2007, at 03:38, Michael Koziarski wrote:>> >> Conceptually I would think that foo.some_association.reload should >> always give you the current value of the association, i.e. some >> instance of an ActiveRecord object, or nil if there is none. In this >> particular edge case what you get back is false instead, which >> doesn''t >> seem quite right - nil would be the correct return value. >> >> Opinions? > > I can''t see any particular reason for this behaviour, if you can > create a patch with tests sounds like a good quick fix.Coolio - It''s at http://dev.rubyonrails.org/ticket/10293 Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---