Hacker News new | ask | show | jobs
by SEMW 4303 days ago
Not using proper foreign keys doesn't mean you can't have associations, it just means that the database won't enforce their integrity. (If you wanted that enforcement in rails, the traditional solution was the Foreigner gem[0]).

(My guess is Rails didn't use proper FKs by default because the default development db (SQLite) originally didn't support foreign keys (though it has for a while now, since 3.9.16), and they presumably wanted to minimise the differences in the way they use different databases).

[0] https://github.com/matthuhiggins/foreigner