gpt4 book ai didi

mysql - 删除 ActiveRecord 对象时出现问题,外键约束失败

转载 作者:行者123 更新时间:2023-11-30 01:37:02 24 4
gpt4 key购买 nike

rails 2.3我已经尝试过...

>> Import::Subscription.all(:conditions => ["account_id = ?", "44"]).destroy_all
NoMethodError: undefined method 'destroy_all' for #<Array:0x106ab4d78>

>> Import::Subscription.all(:conditions => ["account_id = ?", "44"])
>> @subs = _
>> @subs.each { |s| s.destroy }
ActiveRecord::StatementInvalid: Mysql::Error: Cannot delete or update a parent row: a
foreign key constraint fails

@subs[0].delete
ActiveRecord::StatementInvalid: Mysql::Error: Cannot delete or update a parent row: a
foreign key constraint fails

最佳答案

第二次尝试有效,只是一个愚蠢的问题。

关于mysql - 删除 ActiveRecord 对象时出现问题,外键约束失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16742923/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com