diff --git a/app/models/metadata_belongs_to.rb b/app/models/metadata_belongs_to.rb index 27c50f90..0626ba0c 100644 --- a/app/models/metadata_belongs_to.rb +++ b/app/models/metadata_belongs_to.rb @@ -90,7 +90,9 @@ class MetadataBelongsTo < MetadataRelatedPosts private def post_exists? - value.present? && belongs_to.nil? + return true if sanitize(value).blank? + + sanitize(value).present? && belongs_to.present? end def sanitize(uuid) diff --git a/app/models/metadata_has_many.rb b/app/models/metadata_has_many.rb index ec79ddba..61354011 100644 --- a/app/models/metadata_has_many.rb +++ b/app/models/metadata_has_many.rb @@ -73,6 +73,6 @@ class MetadataHasMany < MetadataRelatedPosts end def posts_exist? - has_many.size == value.size + has_many.size == sanitize(value).size end end