2.3.0 :008 > TimeEntry.create(time:1.2, customer_id: 2)
(0.1ms) begin transaction
Customer Load (0.1ms) SELECT "customers".* FROM "customers" WHERE "customers"."id" = ? LIMIT ? [["id", 2], ["LIMIT", 1]]
(0.1ms) rollback transaction
=> #<TimeEntry id: nil, time: 1.2, customer_id: 2, employee_id: nil, created_at: nil, updated_at: nil>
解决办法
belongs_to :doctor, required: false