Add :method => :delete
option with simple_form_for
:
<%= simple_form_for(@journalEntry, :method => :delete) %>
<%= f.button :submit %>
<% end %>
문제
I'm using Ruby on Rails 4 with simple_form. On my delete page, I would like to display a form confirming the user's decision to destroy the resource in question. Here is the code I am using:
<h2>Delete Page</h2>
<p>Are you sure you want to delete <%= @journalEntry.title %></p>
<%= simple_form_for(@journalEntry, :action => 'destroy') do |f| %>
<%= f.button :submit %>
<% end %>
However, this is getting processed by the update
action instead (my server console shows that it is being sent as a PATCH request).
I also tried amending that code to the following, but with the same result:
<%= simple_form_for(@journalEntry, :url => {:action => 'destroy', :id => @journalEntry.id}) do |f| %>
<%= f.button :submit %>
<% end %>
해결책
Add :method => :delete
option with simple_form_for
:
<%= simple_form_for(@journalEntry, :method => :delete) %>
<%= f.button :submit %>
<% end %>