<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-family: 'Lucida Grande'; font-size: 11px; white-space: pre-wrap; "><div>I have this code trying to ensure my reset method works. I want to make sure all the participants have their destroy method called.</div><div><br class="webkit-block-placeholder"></div># in my spec for Room
r = Room.new(:name => 'bob')
r.save
p = Participant.new(:login => 'a', :password => 'b', :password_confirmation => 'b')
p.room = r
p.save!
p.should_receive(:destroy)
r.reset
#in room.rb
def reset
participants.each { |p| p.destroy }
save!
end
</span><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap;">Unfortunately it fails. I print out "p" in both locations and while they have all the same data, they have different memory addresses. I don't know if this is the explanation for the issue but it's all I can find so far.</span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap;">How do I fix this? Thanks!</span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap;"><br class="webkit-block-placeholder"></span></font></div><div><font class="Apple-style-span" face="'Lucida Grande'" size="3"><span class="Apple-style-span" style="font-size: 11px; white-space: pre-wrap;">Glenn</span></font></div></body></html>