I have a model object (let's say Parent) with a has_many association on another model object (Child).
class Parent < ActiveRecord::Base
has_many :children
accepts_nested_attributes_for :children
end
class Child < ActiveRecord::Base
belongs_to :parent
end
On Parent, I want to add code on the before_update callback to set a calculated attribute based on its children.
The problem I've been running into is that when I use the method Parent.update(id, atts), adding atts for new children, those added in the atts collection are not available during before_update (self.children returns the old collection).
Is there any way to retrieve the new one without messing with the accepts_nested_attributes_for?