1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/active_record/associations
Agis- 19b168e611 Only nullify persisted has_one target associations
Since after 87d1aba3c `dependent: :destroy` callbacks on has_one
assocations run *after* destroy, it is possible that a nullification is
attempted on an already destroyed target:

    class Car < ActiveRecord::Base
      has_one :engine, dependent: :nullify
    end

    class Engine < ActiveRecord::Base
      belongs_to :car, dependent: :destroy
    end

    > car = Car.create!
    > engine = Engine.create!(car: car)
    > engine.destroy! # => ActiveRecord::ActiveRecordError: cannot update a
    >   destroyed record

In the above case, `engine.destroy!` deletes `engine` and *then* triggers the
deletion of `car`, which in turn triggers a nullification of `engine.car_id`.
However, `engine` is already destroyed at that point.

Fixes #21223.
2015-08-24 11:49:43 +03:00
..
builder use correct DB connection for generated HABTM table 2015-08-07 12:33:09 -07:00
join_dependency Remove Relation#bind_params 2015-01-27 16:10:03 -07:00
preloader Remove most type related predicates from Column 2015-01-30 11:42:54 -07:00
alias_tracker.rb Move #type_caster to alias tracker initialize 2015-01-02 17:15:31 -05:00
association.rb Skip statement cache on through association reader 2015-08-12 21:17:30 -03:00
association_scope.rb Correct through associations using scopes 2015-06-30 10:00:30 -07:00
belongs_to_association.rb raise ActiveModel::MissingAttributeError when trying to access a relationship without the foreign key attribute 2015-06-16 16:12:52 -03:00
belongs_to_polymorphic_association.rb Fix nil assignment to polymorphic belongs_to 2013-12-18 04:52:24 -07:00
collection_association.rb Skip statement cache on through association reader 2015-08-12 21:17:30 -03:00
collection_proxy.rb Added docs for CollectionProxy#take [ci skip] 2015-08-23 07:28:27 +05:30
foreign_association.rb Share foreign_key_present? implementation in _has_ associations 2014-12-31 00:19:09 +03:00
has_many_association.rb Merge pull request #19683 from tristang/require-option-for-counter-cache 2015-08-13 17:51:07 -03:00
has_many_through_association.rb Revert "Revert "Reduce allocations when running AR callbacks."" 2015-07-16 01:02:15 +08:00
has_one_association.rb Only nullify persisted has_one target associations 2015-08-24 11:49:43 +03:00
has_one_through_association.rb Rename update_attributes method to update, keep update_attributes as an alias 2013-01-03 11:51:21 -05:00
join_dependency.rb Merge pull request #16989 from Empact/reload-cache-clear 2015-02-20 17:45:10 -02:00
preloader.rb Correct error message in Standard American english and add a test case for the same. 2015-08-18 11:39:52 +05:30
singular_association.rb Skip statement cache on through association reader 2015-08-12 21:17:30 -03:00
through_association.rb Fix misleading errors for has_one through relations 2015-07-22 00:51:23 +03:00