문제

I want to add a confirmation box before destroying an object in a controller. Basically, create the

data: {confirm: "You sure" }

but in a controller during object.destroy Thank you

도움이 되었습니까?

해결책

you can only interact with the user in the view layer, so you need to make that confirmation before you go into the destroy method

다른 팁

You can warn the user by simply add the confirm option to the link, and it will pop up a window to notify the user, same as using alert function in javascript.

<%= link_to 'delete', delete_obj_path(obj), :method=>'delete', :confirm=>'You sure?'%>

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top