This project is archived and is in readonly mode.

#1305 ✓resolved
Chris Elledge

has_one dependent nullify deletes associated object on change

Reported by Chris Elledge | October 30th, 2008 @ 09:36 PM | in 2.x

Using Rails 2.1.1

class User < ActiveRecord::Base
  has_one :device, :dependent => :nullify
end
u = User.find(1)
u.device = Device.find(1)
u.device = Device.new
Device.find(1)
  ActiveRecord::RecordNotFound: Couldn't find Device with ID=1

From the description of :dependent => :nullify it doesn't sound like it should be deleting the device that was previously assigned. It doesn't do this if :dependent is not set.

Why should :dependent => :nullify delete objects like this when the default setting doesn't?

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages