Destroying a record with a has_one association with :dependent => :nullify triggers update callbacks #8822

Closed
phene opened this Issue Jan 8, 2013 · 5 comments

Projects

None yet

4 participants

@phene

Because of the recent changes with update_attribute/update_column, the process of deleting an object with a has_one :foo, :dependent => :nullify causes callbacks to be triggered on Foo. Either the documentation needs to be updated (which states that it won't trigger callbacks) or the behavior needs to be fixed.

@steveklabnik
Ruby on Rails member
@jonleighton
Ruby on Rails member

I don't think a nullify should trigger callbacks. @rafaelfranca can you chip in? was this intentional?

Also, is this a 4.0 issue or a 3.2 issue as well?

@rafaelfranca
Ruby on Rails member

I didn't changed the behaviour. I only reverted the changes.

It is this way since at least Rails 3.1 https://github.com/rails/rails/blob/3-1-stable/activerecord/lib/active_record/associations/has_one_association.rb#L39

If we are going to change the behaviour we need to document it.

@rafaelfranca
Ruby on Rails member

And I think it should trigger callbacks, since the object was updated and we need to change the value of updated_at.

@jonleighton
Ruby on Rails member

Ok, thanks. I'm not sure either way but I don't think it's worth changing if it's always been like this. Closing.

@jonleighton jonleighton closed this Mar 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment