Hi!
I've got model A and model Attach. I'm editing my A form with nested attributes for :attaches. And when I am deleting all attaches from A via accepts_nested_attributes_for how can I get after_update/after_save callbacks for all of my nested models? Problem is that when I am executing callbacks in model A they are executed right AFTER model A is updated and BEFORE model Attach is updated, so I can't, for example, know if there is NO ANY attaches after I delete them all :).
Look for example: my callback after_save :update_status
won't work properly after I delete all of my attaches.
model A
after_save :update_status
has_many :attaches
accepts_nested_attributes_for :attaches, :reject_if => proc { |attributes| attributes['file'].blank? }, :allow_destroy => true
def update_status
print "\n\nOUPS! bag is empty!\n\n" if self.attaches.empty?
end
end
model Attach
belongs_to A
end
I am using rails 3 beta