Rails link_to code: <%= link_to "<i class='fa fa-trash'></i>".html_safe, resource_path(id: id), method: :delete, data: { confirm: "Are you sure...?" }, class: "text-center dropdown-item text-danger bg-light-danger", title: "Delete"%>
Html version of above link_to tag:
<a data-confirm="Are you sure...?" class="text-center dropdown-item text-danger bg-light-danger" title="Delete" rel="nofollow" data-method="delete" href="/resource/1"><i class="fa fa-trash"></i></a>
The above code is taking always to show instead of destroy. may be because of some jquery or other js library. same code is working in some of the projects but not working in some of the projects. checked with different rails version but it's not because of rails version.
Tried with using different Jquery CDN. also installed jquery using yarn in latest rails 6 and 7 version but issue is same. Some reference solutions that didn't work in my case. Issue with delete action , Using link_to with delete action in rails , Why Rails "link_to" does not work for delete action?