“级联删除”在蒙古人中
例如,
User
references_many :answers
Answer
references_many :users
假设我们要删除给定用户的答案,我们如何才能删除用户/答案对象上的引用?
For example
User
references_many :answers
Answer
references_many :users
Say we are deleting answers for a given user, how do we do it such that both the references on the user/answer objects are deleted?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
级联删除
与 ActiveRecord 类似,如果您希望在删除父记录时删除子关系关联,只需在references_one 或references_many 宏上提供:dependent 选项即可。
Cascading Removals
Similar to ActiveRecord, if you want child relational associations to be deleted when the parent record is deleted, simply supply the :dependent option on the references_one or references_many macro.