turbolinks / turbolinks-ios

Native iOS adapter for building hybrid apps with Turbolinks 5
MIT License
881 stars 92 forks source link

delete method not support? #123

Closed watsy0007 closed 6 years ago

watsy0007 commented 6 years ago

eex(elixir render) code

<%= link "Delete", to: user_path(@conn, :delete, user), method: :delete, data: [turbolinks: true, remote: true], class: "btn btn-danger btn-xs" %>

html code

<a class="btn btn-danger btn-xs" data-csrf="Ym==" data-method="delete" data-remote="true" data-to="/users/6" data-turbolinks="true" href="/users/6">Delete</a>

but when i click a tag. not work. it becomes post method!!!

default
pbmarcano commented 6 years ago

Look at https://github.com/turbolinks/turbolinks-ios/issues/103 's last two answers and see if they help you. A little work is needed on the iOS side.

zachwaugh commented 6 years ago

Rails always sends DELETE as a POST to work in all browsers that may not support making DELETE requests directly, using a hidden _method=DELETE field:

Because submitting forms with HTTP methods other than GET and POST isn't widely supported across browsers, all other HTTP methods are actually sent over POST with the intended method indicated in the _method parameter. Rails automatically detects and compensates for this.

http://guides.rubyonrails.org/working_with_javascript_in_rails.html#data-method

watsy0007 commented 6 years ago

thanks @zachwaugh @pbmarcano