AssociationProxy#reset

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

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.

Coolio - It's at http://dev.rubyonrails.org/ticket/10293

Fred