# Puzzled by ActiveRecord

**URL:** <https://www.ruby-forum.com/t/puzzled-by-activerecord/116441>\
**Category:** Rails\
**Created:** [October 5, 2007, 3:58pm UTC](https://www.ruby-forum.com/t/puzzled-by-activerecord/116441 "2007-10-05T15:58:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [October 5, 2007, 3:58pm UTC](https://www.ruby-forum.com/t/puzzled-by-activerecord/116441/1 "2007-10-05T15:58:24Z")

</div>

Dear list,

At the moment I am working on an app which has a good few models and  
associations. In short:  
A :has\_many B  
B :belongs\_to A

Now I want to update A when I have saved B, so I wrote a after\_save  
filter. However the update of A entails looking at all associated B’s  
so I wrote something like:  
self.Bs.each do |b|  
#do something  
end

This did not work. It iterated alright but almost all attributes in B  
were empty. Writing:  
self.Bs.find(:all).each do |b|  
#do something  
end

This did work! Why?

With kind regards,  
Harm
