This line completes without errors, but create an empty model, i.e. the attributes in the where query are not included:
SubModel.where("attribute = ?", 'value').first_or_create!
And this line throws an exception:
SubModel.find_or_create_by(attribute: value)
This line completes without errors, but create an empty model, i.e. the attributes in the where query are not included: SubModel.where("attribute = ?", 'value').first_or_create!
And this line throws an exception: SubModel.find_or_create_by(attribute: value)