Hi...I am a beginner in Rails and I read that the Rails enforces the foreign key relationships at the model level and also at the database level in the migration file, while creating the table. Is it really necessary and what kind of advantage does it provide
+2
A:
It is not strictly required, however it is a good idea both from the perspective of documenting that the relationship exists, and to help to maintain database integrity and bring business logic errors to light more quickly. It is also generally a good idea to follow rails conventions rather than swim against the tide, unless you have a very compelling reason to do so.
frankodwyer
2010-05-24 16:47:36