Today I Learned how to Generate a ERD for Rails Application

Back in the day Rails apps didn’t add foreign keys to database tables.  Believe it or not this was a feature not a bug.  The idea was that you shouldn’t “repeat” the relationship between you models in the code and in the database.  It wasn’t until Rails 4.2 that support was added for foreign keys.  

As you can probably guess I think this was a mistake.  If you have worked with a database without any foreign key constraints you quickly run into data integrity issues.  I don’t care how careful you think you are you will eventually screw up.  If not you then another person or application will corrupt your data.  Line items not attached to an order, address without customers, cats and dogs living together, etc.

[Read More]