Hacker News new | ask | show | jobs
by manojlds 4312 days ago
Isn't Rails getting real foreign keys only in yet to release 4.2?
1 comments

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