Puzzled by ActiveRecord

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

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

This did work! Why?

With kind regards,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs