How to ask for confirmation before performing an actionin ruby on rails?
I have a delete button where I want to ask for confirmation before deleting the record. I want to put a custom message in German and German terms for 'OK' and 'cancel'.
<%= button_to 'Record löschen', action: 'delete_all_record', id: params[:id], redirect_back: params[:redirect_back]%>
so, when I press record löshen button it should ask for confirmation and then perform the deletion action.
You could use button_to
with the data attribute confirm
like this:
<%= button_to(
'Record löschen',
{ action: 'delete_all_record', id: params[:id] },
data: { confirm: "Sind Sie sicher?" } %>