belongs_to_types() function; fix is_foreign_key

is_foreign_key previously checked whether the field name ended with
"_id" and whether a module of the same name was loaded. This patch
makes it smarter by checking if the (.*)_id name matches any of the
declared -belongs_to associations.