There is one plugin that I use in all my projects, and that is the Foreign Key Migrations plugin from RedHill. Defining foreign keys can’t become easier then this. Since as far as I know, Rails migrations don’t set foreign keys in your database, so this is the best solution. It uses SQL-92 syntax and as such should be compatible with most databases that support FK constraints.
You can even use it for legacy column names that don’t end with “id”. There is even a generator for creating FK’s on a database that currently has none, so you can easily start using it even at the end of a project.
You can download the EDGE, 2.0 stable, 1.2 stable or 1.1.6 release, depending on your Rails version. Don’t forget the you need the RedHill on Rails Core .