-2
= link_to multimedium_path(f), method: :delete, data: { confirm: 'Are you sure to delete this multimedia?' } do

     i.fa.fa-trash.fa-lg.mr-2.text-danger 

When i use link_to, the button is redirecting me to show method of the multimedia controller. Using button_to solves this problem, but the confirm is not working properly.

= button_to multimedium_path(f), method: :delete, data: { confirm: 'Are you sure to delete this multimedia?' } do

     i.fa.fa-trash.fa-lg.mr-2.text-danger 

Can someone explain to me what is happening? Thank you!!!

Sheriff Hussain
  • 224
  • 2
  • 12

1 Answers1

0

Probably It's about your layout html code. I had the same problem. If you deleted all the code that rails gives you for layout, it'll do this. So this is the code you need to put in your layout's which you wanna make action as destroy. Put in head tag.

<head>
     <%= csrf_meta_tags %>
     <%= csp_meta_tag %>
     <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
     <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
       .
       .
       .
</head>

And this is because as you know html don't(like to idk why) destroy by itself... you need to put certain codes for example like this to make html ruthless :)

Kiran Maniya
  • 8,453
  • 9
  • 58
  • 81