本文介绍了在rails中的参照完整性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我刚刚遇到了一个事实,即rails不支持关于外键的引用完整性,并且相当惊讶。那么,管理这个最好的方法是什么?是否有一个轨道的方式来处理引用完整性?



理想情况下,应用程序不应该处理所有这一切;数据库应该。我在看外国人的插件。我不知道这个方法是否有缺点。这是一个Rails ActiveRecord的设计决定。
这是一个Rails ActiveRecord的设计决定。

解决方案

-



所以答案是数据库处理的参照完整性不是Rails方式。


So, I just came across the fact that rails does not support referential integrity regarding foreign keys and was fairly surprised. So, what's the best way to manage this? Is there a "rails" way for dealing with referential integrity?

Ideally the app should not have to deal with all this; the db should. I was looking at plugins like foreigner. I wonder if this method has some shortcomings. How is this normally dealt with in rails?

解决方案

It's a design decision for Rails ActiveRecord.

Choose a single layer of cleverness - DHH

So the answer is that referential integrity handled by the DB is not the Rails way at all.

这篇关于在rails中的参照完整性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 22:36