Checking foreign keys on validate

Hi,

I’ve noticed that by default AR#validate doesn’t check whether a given
foreign key relationship is actually valid. So if you have a book and
you set its author_id to some number that doesn’t correspond to an
Author in the authors table, then it valid? will just return true. I
guess this is a rare condition because normally the author_id would come
from a pre-populated, but I just ran into this issue in one of my unit
tests.

So I guess my question is: is their an easy way to check if the
associations exist before inserting/updating a record?

Jeroen