#180 invalid
Elliott Mason

Weird #reload behavior

Reported by Elliott Mason | March 13th, 2008 @ 01:52 PM

I'm trying to troubleshoot another bug and kept wondering why my tests passed but similar code in practice did not give proper results.

#Assume Topic has_many Posts and Post belongs_to Topic.

p = Post.new
p.topic = Topic.new
p.topic_id == p.topic.id #true
p.topic_id == p.topic.id #true

#That's cool, but...
p = Post.all.last
p.topic #now returns nil
p.topic_id #now returns nil

Which leads me to conclude that #reload doesn't seem to be reloading properly in all cases. The spec written for the method works fine. For some reason in the context of associations it just behaves differently.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

People watching this ticket