create_table "cars_parts", force: :cascade do |t|
t.integer "car_id"
t.integer "part_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["car_id"], name: "index_cars_parts_on_car_id"
t.index ["part_id"], name: "index_cars_parts_on_part_id"
end
You have a not null constraint on created_at in cars_parts.
In the error you can see that it says created_at can't be Null:
SQLite3::ConstraintException: NOT NULL constraint failed: cars_parts.created_at
So in your yml file you need to set created_at:
one:
car_id: 1
part_id: 1
created_at: Time.current
updated_at: Time.current
two:
car_id: 2
part_id: 2
created_at: Time.current
updated_at: Time.current
EDIT:
As Sebastian pointed out, this is not an ideal solution, AR should automatically be adding these timestamps.
The real problem is that you named your model CarParts so it's not finding the model. You should rename the file to cars_part.rb and the model name to CarsPart.
Other people having this problem were attributing the cause to the model not being found:
https://github.com/rails/rails/issues/23316