Hi, I''ve been digging a bug for 3 days. I pin-pointed the problem line of codes. It''s not my code but the activerecord code. The problem is with the activerecord-3.0.3/lib/active_record/nested_attributes.rb line# 376: association.send(:add_record_to_target_with_callbacks, existing_record) if !association.loaded? && !call_reject_if(association_name, attributes) I realized that the line was changed from activerecord-3.0.0. (which works well) It used to be: association.send(:add_record_to_target_with_callbacks, existing_record) unless association.loaded? The problem is: _destroy option doesn''t work for nested attributes if the association is not loaded. I don''t think that''s the feature. Here''s how I tested it in console. (I intentionally removed some outputs for simplicity.) Loading development environment (Rails 3.0.3) ruby-1.8.7-p302 > post=Post.find 204 ruby-1.8.7-p302 > post.attachments.loaded? => false ruby-1.8.7-p302 > post.attributes={"attachments_attributes"=>{"0"=>{"id"=>"44", "_destroy"=>"1"}}} ruby-1.8.7-p302 > post.save => true ruby-1.8.7-p302 > post.attachments.map { |i| i.id }.join(", ") => "44, 45, 46, 47, 48, 49" #44 is still there. ruby-1.8.7-p302 > post.attributes={"attachments_attributes"=>{"0"=>{"id"=>"44", "_destroy"=>"1"}}} # Now I try to destroy it again when the attachments are loaded. ruby-1.8.7-p302 > post.save => true ruby-1.8.7-p302 > post.attachments.reload # To make sure that attachments are reloaded after the change. ruby-1.8.7-p302 > post.attachments.map { |i| i.id }.join(", ") => "45, 46, 47, 48, 49" # Now 44 is gone. Can anybody confirm that this is a bug? Thanks. Sam -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.