How can one use the same lookup table for multiple columns in the same
table?
e.g. let’s say I have a lookup table with automobile makes (Audi, BMW,
Chevrolet) , and then a “drivers” table with columns for primary car
make, secondary car make, etc. I can’t very well name them both
make_id…?
How can one use the same lookup table for multiple columns in the same
table?
e.g. let’s say I have a lookup table with automobile makes (Audi, BMW,
Chevrolet) , and then a “drivers” table with columns for primary car
make, secondary car make, etc. I can’t very well name them both
make_id…?
Change the key name in your has_one/belongs_to lines with:
:foreign_key - specify the foreign key used for the association. By
default this is guessed to be the name of this class in lower-case and
“_id” suffixed. So a Person class that makes a has_one association will
use “person_id” as the default foreign_key.