I'm trying to find a way to delete the images uploaded from activeadmin using activestorage. I managed to show all the images in the show view and the edit of the resource but i can't seem to find the way to delete each image if i want. my model code:
class Category < ApplicationRecord
has_many_attached :images
end
And the activeadmin resource file:
ActiveAdmin.register Category do
permit_params :category_name, :description, :photo_cover, images: []
index do
selectable_column
id_column
column :category_name
column :created_at
actions
end
show do |t|
if t.photo_cover.attached? && t.images.attached?
attributes_table do
row :category_name
row :description
row "images" do |m|
m.images.each do |img|
span do
image_tag(img)
end
end
end
end
else
attributes_table do
row :category_name
row :description
end
end
end
form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs "Basic Info" do
f.input :category_name
f.input :description
end
f.inputs do
f.input :images, as: :file, input_html: { multiple: true }
end
if f.object.images.attached?
f.object.images.each do |img|
span do
image_tag(img)
end
end
end
f.actions
end
end
Thank you in advance!!