Reputation: 4691
I want to change my delete not to delete but to update a field on the record called "deleted"
'Are you sure?', :method => :delete %>Seems like this should work, but it doesnt:
true, :confirm => 'Are you sure?', :method => :post %>Upvotes: 2
Views: 1058
Reputation: 32335
There's no automatic way to do this through a view helper such as link_to. Your actions in your controller need to actually do this for you.
If you never want to delete a document through your destroy action, then just rewrite that action to set its 'deleted' attribute to true instead of actually destroying it. That way you can continue to use your original link. so:
class Document < ActiveRecord::Base
# DELETE /documents/:id
def destroy
@document = Document.find(params[:id])
@document.deleted = true
@document.save
redirect_to documents_path
end
end
with
<%= link_to 'Destroy', document, :confirm => 'Are you sure?', :method => :delete %>
Upvotes: 2