Some notes on syntax on models always looking up.
- Change Migration to
null: true
e.g.t.references :vehicle, null: true, foreign_key: true
- add
optional: true
to model e.g.belongs_to :vehicle, optional: true
e.g. key is driver_id table is employee
- Change Migration so foreign_key is explict to table e.g.
foreign_key: { to_table: :employees }
- Change Model to define class e.g.
, class_name: "Employee"