I have a problem when i update an object in a has_many association :
l = self.posts.where(...)
l.each do |item|
item.increment!(:nb, 2)
item.update
item.save
end
When I do :
logger.info Post.all.inspect
logger.info self.posts.inspect
The posts are updated with the first line but not with the second
Is there a way to force the update or am i doing something wrong? I also tried to disable the cache but it still the same problem.
You can do
By default,
force_reload
isfalse
.