Reputation: 15136
I've used he rails engine to create a demo app. Everything works fine, except the "Destroy" function deos not do anything. There is no error message.
Can anyone guess as to why nothing would happen, even though there is no error message?
The function (auto-created) is:
def destroy
@term = Term.find(params[:id])
@term.destroy
respond_to do |format|
format.html { redirect_to terms_url }
format.json { head :ok }
end
end
and the HTMl part is:
<td><%= link_to 'Destroy', term, confirm: 'Are you sure?', method: :delete %></td>
I dont even get the confirmation question. Checked, and JavaScript is enabled.
Upvotes: 0
Views: 2369
Reputation: 37507
It's a pretty common question, sounds like you're not including the javascript that shows the confirmation and implements the delete method across all browsers that don't support it - did you include the rails javascript libraries?
Rails 3.1
<%= javascript_include_tag "application" %>
Rails 3
<%= javascript_include_tag :defaults %>
see link_to delete url is not working
Upvotes: 5
Reputation: 233
I think your link_to signature is wrong. Try:
<%= link_to 'Destroy', term, :confirm => 'Are you sure?', :method => :delete %>
Upvotes: 0