这是脚手架生成的代码
# DELETE /swimming/classtimes/1
# DELETE /swimming/classtimes/1.json
def destroy
@swimming_classtime = Swimming::Classtime.find(params[:id])
@swimming_classtime.destroy
respond_to do |format|
format.html { redirect_to swimming_classtimes_url }
format.json { head :no_content }
end
end
此 html 代码将发送 html 格式的请求
<a href="/swimming/classtimes/42" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a>
或导轨代码
<%= link_to 'Destroy', swimming_classschedule, :method =>:delete, data: { confirm: 'Are you sure?' }%>
如何告诉动作返回 json 格式?