gpt4 book ai didi

ruby-on-rails - rails :dependent and :delete

转载 作者:行者123 更新时间:2023-12-02 06:45:43 24 4
gpt4 key购买 nike

我正在运行 Rails 2.0.2,但无法在我的 AR 关联中使用 :dependent => :delete

 has_many :items, :dependent => :delete

我收到这个错误。

  The :dependent option expects either :destroy, :delete_all, or :nullify (:delete)

我无法找到 :delete_all 的文档来查看它是否符合我的要求。它基本上与删除相同吗? :delete 是最近添加到 Rails 中的,而不是我正在使用的版本吗?

最佳答案

这是 relevant documentation for Rails 2.0.2 :

if set to :destroy all the associated objects are destroyed alongside this object by calling their destroy method. If set to :delete_all all associated objects are deleted without calling their destroy method. If set to :nullify all associated objects’ foreign keys are set to NULL without calling their save callbacks.

railsbrain.com 是查找特定 Rails 版本特定文档的好地方。

关于ruby-on-rails - rails :dependent and :delete,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/738906/

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