From e233fbe1d88d6e8759e31716c94dc3fb6292b975 Mon Sep 17 00:00:00 2001 From: zmagod Date: Tue, 28 Nov 2017 11:01:07 +0100 Subject: [PATCH] fix image removing from tinymce --- app/helpers/tiny_mce_helper.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/helpers/tiny_mce_helper.rb b/app/helpers/tiny_mce_helper.rb index d28750119..22609447e 100644 --- a/app/helpers/tiny_mce_helper.rb +++ b/app/helpers/tiny_mce_helper.rb @@ -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