fix for image destroy
This commit is contained in:
parent
73e8a8b4ed
commit
604fede5a7
|
|
@ -80,9 +80,13 @@ module PsAdmin
|
||||||
image = Image.where(id: params[:id]).first
|
image = Image.where(id: params[:id]).first
|
||||||
unless image.blank?
|
unless image.blank?
|
||||||
if image.cover.eql?(true)
|
if image.cover.eql?(true)
|
||||||
img = Image.where('imageable_type = ? AND imageable_id = ? AND id != ?', image.imageable_type, image.imageable_id, image.id).first
|
img = Image.by_image_type(image.imageable_type)
|
||||||
img.cover = true
|
.where('imageable_id = ? AND id != ?',
|
||||||
img.save
|
image.imageable_id, image.id).first
|
||||||
|
unless img.blank?
|
||||||
|
img.cover = true
|
||||||
|
img.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
image.destroy
|
image.destroy
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue