dependent: :destroy
ActiveRecord モデルで循環オプションを使用しても安全ですか?
class Student < ActiveRecord::Base
has_one :user, dependent: :destroy
end
class User < ActiveRecord::Base
belongs_to :student, dependent: :destroy
end
を削除するuser
と、関連する が削除されstudent
ます。およびその逆。