Understanding the difference between has_one/foreign_key and add_reference

#1
I'm at the point of my project where I am building the lookup tables for my main table.

I understand that to create foreign key references I have to use `add_reference` when creating the table.

But then I also have to use the `has_one` along with `foreign_key` association.

But I'm trying to understand why I need to do both and what's the difference. If I create a foreign key and reference when creating the table, why do I have to define it again with the association? Why can't rails detect the association from reference (add_reference)?
 
Top