fix image removing from tinymce

This commit is contained in:
zmagod 2017-11-28 11:01:07 +01:00
parent dec1e53b53
commit e233fbe1d8

View file

@ -54,6 +54,12 @@ module TinyMceHelper
end
def destroy_removed_tiny_mce_assets(ids, ref)
ref.tiny_mce_assets.where.not('id IN (?)', ids).destroy_all
# need to check if the array is empty because if we pass the empty array
# in the SQL query it will not work properly
if ids.empty?
ref.tiny_mce_assets.destroy_all
else
ref.tiny_mce_assets.where.not('id IN (?)', ids).destroy_all
end
end
end