1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/schema
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
..
mysql2_specific_schema.rb Add :charset and :collation options support for MySQL string and text columns 2015-03-06 18:56:19 +09:00
mysql_specific_schema.rb Add :charset and :collation options support for MySQL string and text columns 2015-03-06 18:56:19 +09:00
oracle_specific_schema.rb tests, favor public API over inspecting columns where possible. 2014-12-01 16:57:48 +01:00
postgresql_specific_schema.rb Correctly handle array columns with defaults in the schema dumper 2015-06-11 16:50:25 -06:00
schema.rb Only nullify persisted has_one target associations 2015-08-24 11:49:43 +03:00
sqlite_specific_schema.rb fk: use random digest names 2014-06-26 22:03:49 +02:00