Delete function not working

I’m trying to create a delete button for images that has been uploaded via active storage.

I’m using devise for sign up, wicked wizard for multi step and cancancan for authorization

But I get this error, and I can’t figure out how to make it work.

my form

<%= form_for @user, url: wizard_path, method: :put do |f| %>

<% if @user.clinic_images.attached? %>

<% @user.clinic_images.each do |image| %>

<%= image_tag(image.variant(resize: "100x100")) %>

<%= link_to ‘Delete this image’, delete_image_attachment_registration_url(image.signed_id),

method: :delete,

data: { confirm: ‘Are you sure?’ } %>

<% end %>

<% end %>

<% end %>

Routes.rb

Rails.application.routes.draw do

mount RailsAdmin::Engine => ‘/admin’, as: ‘rails_admin’

devise_for :users, controllers: {:registrations => “users/registrations”}

resources :registration_steps


root ‘pages#index’

get ‘about’, to: ‘pages#about’

get ‘team’, to: ‘pages#team’

get ‘faqs’, to: ‘pages#faqs’

get ‘faqspractitioners’, to: ‘pages#faqspractitioners’

get ‘faqsusers’, to: ‘pages#faqsusers’

get ‘login’, to: ‘pages#login’

get ‘signup’, to: ‘pages#signup’

get ‘search’, to: ‘pages#search’


resources :registration do

member do

delete :delete_image_attachment

end

end

end

registrations_controllers.rb

def delete_image_attachment

@image = ActiveStorage::Blob.find_signed(params[:id])

@image.purge_later

redirect_to root_path

end

I’m new to ruby and rails, and trying to learn.

Try naming your action destroy instead of delete