Reference integrity in rails

So, I just came across the fact that the rails do not support referential integrity with respect to foreign keys and were quite surprised. So what is the best way to handle this? Is there a โ€œrailsโ€ way to solve referential integrity?

Ideally, an application should not deal with all of this; db should. I looked at plugins like a foreigner. I wonder if this method has some disadvantages. How is it usually seen in rails?

+3
source share
2 answers

This is a design solution for Rails ActiveRecord.

. , - , . , , - .

- DHH

, , , , Rails.

+5

,

,:dependent => :restrict

has_one has_many!

,

Active Record

+1

Source: https://habr.com/ru/post/1758694/


All Articles