本文介绍了habtm关系不支持:dependent选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HABTM关系是否不支持:dependent
选项吗?
Is it true that HABTM relationships do not support the :dependent
option?
class Person < ActiveRecord::Base
has_and_belongs_to_many :posts, :dependent => :destroy
end
我正在尝试Rails edge.
I am trying rails edge.
推荐答案
是的,它不支持. 请参阅文档.通常,habtm
仅用于非常简单的情况,如果您开始需要更复杂的内容,则应切换到has_many :through
.
Yep, It doesn't support it. See the docs. Generally habtm
is meant only for very very simple cases and if you start needing more complex things you should switch to has_many :through
.
这篇关于habtm关系不支持:dependent选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!