0
def destroy
@idea = Idea.find(params[:id])
@idea.destroy
flash[:success] = "The idea was successfully deleted!"
redirect_to root_path
end
查看
<%= link_to 'Destroy', idea_path(idea), :method => :delete, class: 'btn btn-sm btn-danger', data: {confirm: "Are you sure?"} %>
爲什麼它不工作?這引發了一些錯誤,如:
ActionController::InvalidAuthenticityToken in IdeasController#destroy
def handle_unverified_request
raise ActionController::InvalidAuthenticityToken
end
您是否從應用程序佈局中刪除了<%= csrf_meta_tags%>? – Sculper
是啊!意外。 現在沒事了! 可以告訴我<%= csrf_meta_tags%>的功能嗎? – ibya404