Fix a bug that caused has_many fields to be lost