Hacker News new | past | comments | ask | show | jobs | submit login

> I remember when foreign keys were taboo among Rails developers because Rails didn't have a way to express them in its DSL.

What? Relationships (and thus foreign keys) have been around since before 1.2.




Relationships are not foreign keys. Relationships (has_many, belongs_to) are a Rails construct. Foreign keys are a database thing.

I started using Rails almost at the very beginning. See https://stackoverflow.com/questions/2373262/are-foreign-keys... from 2010 for a bunch of links to DHH opinion on the matter (from 2006.)

Foreign keys made it into the DSL with Rails 4.2

http://guides.rubyonrails.org/4_2_release_notes.html#foreign...

https://apidock.com/rails/ActiveRecord/ConnectionAdapters/Sc...

Before that we were using gems or writing SQL into the up and down migrations.

https://robots.thoughtbot.com/referential-integrity-with-for... (from December 2014)


Just to be clear, you keep saying "foreign key", but the phrase most people know is "foreign key constraint" (because it's just a constraint).




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: