Adding foreign key constraints in Rails

Here’s a great article about adding foreign key constraints to handle cascading deletion of records. It’s a good idea to handle foreign key constraints through the database because Rails doesn’t always fire an object’s callbacks upon deletion. So if you have a dependent: :destroy callback set up, it might get skipped in some situations.

https://robots.thoughtbot.com/referential-integrity-with-foreign-keys

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s