Had to remove a belongs_to for a hack to fix record must exist error

I had to remove a belongs_to association from a model to fix the error record must exist referring to the would be associated model but the association still exists with has_many in the other model

Could try adding optional: true at the end, so it would look something like this:

class Order < ApplicationRecord
  belongs_to :customer, optional: true
end

Maybe if you show some code how you’re creating these objects that will help diagnose the problem?