question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

anchors with delete method do not redirect

See original GitHub issue

Expected Behaviour

Clicking on <a class="text-danger" data-method="delete" data-confirm="Are you sure you want to delete this contact?" data-turbo="false" href="/sellers/2/contacts/10">Delete</a> is expected to make a delete request to the server, where the controller action performs a redirect, and the page respond with a redirect

Controller

  def destroy
    @contact.destroy

    flash[:success] = 'Contact Deleted'
    redirect_to seller_contacts_path(current_organization)
  end

Actual Behaviour

The controller action is hit and the browser receives the response to redirect, however the DOM remains unchanged

Steps to Reproduce

  1. Create an anchor with a delete method, confirm text and data-turbo=“false”
  2. Create a controller destryo action that responds with a redirect

Repo (if possible)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
KonnorRogerscommented, Jul 16, 2021

@scottbarrow pretty sure this was due to bad querySelectors on my part.

This should be fixed now in 0.3.0.beta-29

Feel free to reopen this if it doesnt fix it.

1reaction
KonnorRogerscommented, Jul 16, 2021

@scottbarrow pretty sure I found the issue. Pushing up a fix shortly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is this OK to redirect to `PUT`, `DELETE` methods?
Simply create URL /users/37/delete , do all your validation here and delete it on success. If you want to have REST API, keep...
Read more >
"data-turbo-method: delete" should use POST with ...
When an <a> link attributed with 'data-turbo-method: delete' is clicked turbo intercepts the click and issues a DELETE request to the server.
Read more >
Send a delete request and redirect back, 405 error
I send a delete request from Front end: this.$inertia.visit('/test/100', { method: 'delete', onSuccess: () => { this.$notify.success('success') }, onEr.
Read more >
Replacing anchor links with JavaScript
The solution is to use the scrollIntoView method which is supported in all major browsers. It scrolls to the (any) selected element without...
Read more >
Help:Redirects
Deleting a redirect ... There's generally no need to delete redirects. They do not occupy a significant amount of database space. If a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found