Link_to not working with Ruby on Rails/ Devise Gem

Hi Everyone
I will appreciate if anyone please help me with this issue,

My controller action is:

def destroy
respond_to do |format|
format.html { redirect_to cryptos_url, notice: ‘it was successfully destroyed.’ }
format.json { head :no_content }

the index.html.erb is:
<%= link_to ‘Delete’, crypto_path(@crypto), data: {turbo_method: :delete} %>

** button_to works though.*

The reason why it is not working is because with data-turbo-method attribute it will make a fetch request and will expect a turbo-response and not navigate. If you add data-turbo-frame="_top" it will tell it to perform the navigation on the page and will redirect you correctly.

<%= link_to ‘Delete’, crypto_path(@crypto), data: {turbo_method: :delete, turbo_frame: "_top" } %>

Thank you [yunggindigo] for your response. I tried it and it still not working.

<a data-turbo-method="delete" data-turbo-frame="_top" href="/cryptos/3)">Delete</a>

That’s what I got in my source page for the delete method

This function is not executed it

def destroy

     puts @crypto

    puts ["hello hello hello destroy"]


    respond_to do |format|

      format.html { redirect_to cryptos_url, notice: 'Crypto was successfully destroyed.' }

      format.json { head :no_content }



What does the rails logs say when u make the request

You need to add a status: :see_other inside the redirect_to method this is because turbo needs that to perform the navigation. Here is the docs

Redirect in controller would look like this

format.html { redirect_to cryptos_url, notice: "...", status: :see_other }

To correct my earlier answer I thought that data-turbo-method will do a request without navigating but that is false. It will still navigate the page correctly so that means all you need is the data-turbo-method method on the link and then the new status: :see_other in the controller response

Still not working. Last time I had a problem to log out and I did change the method delete to get in the config file. There is a lot of data in the terminal to post here.

Do you have LinkedIn or GitHub to share the code with you?

That change is dangerous, because often browsers will pre-fetch links to speed up the page transitions. You do NOT want to pre-fetch a logout link. That’s why they are set to use DELETE as the verb. Rails translates them into a POST with a _method key of delete, but pre-fetchers don’t submit forms, and that keeps you safe.


Oh thank you Walter. I will try to put the delete method back but I still need to figure out why I cannot log out.