我试图通过JSON从表中删除一行。 删除按钮如下:
<div><input class="" type="checkbox" name="Mondays[]" value="5.00-6.00pm: 4-6 year olds FULL" id="Mondays_7_1_1" />
<span name="Mondays_7_1_1">5.00-6.00pm: 4-6 year olds FULL</span>
...
<script>
var monSpan = document.getElementsByName('Mondays_7_1_1')[0];
monSpan.style.color = "red";</script>
控制器:
link_to('Delete', product, method: :delete, data: { confirm: 'Are you sure?' }, remote: true)
当我按下按钮时,记录被删除,但控制台出错:
ActionView :: MissingTemplate缺少模板产品/销毁
我做错了什么?
答案 0 :(得分:1)
def destroy
@product.destroy
respond_to do |format|
format.html { redirect_to home_path, notice: 'Article was successfully destroyed' }
format.json { head :no_content }
end
end
如果删除了产品,您应该重定向到其他页面。