我有两个模型:
我有一个销毁链接:
site
和heading
,其中site拥有多个headings。我有一个销毁链接:
<%= link_to site_heading_path(@site, @heading), data: { 'turbo-method': :delete, 'turbo-confirm': "Are you sure?"} do %>
<i class="ti ti-trash"></i> Destroy
<% end %>
以下是我的标题控制器方法,基本上只是默认的操作:
def destroy
@heading.destroy
respond_to do |format|
format.html { redirect_to site_path(@site), notice: "Heading was successfully destroyed." }
format.json { head :no_content }
end
end
我已经写了这段代码一千次了,但在我的全新的Rails 7基础代码中,它却表现出奇怪的行为。
期望结果:
标题被删除,我被重定向到/sites/1
实际行为:
- 标题被删除(好的)
- 我可以看到重定向(很好)
- TURBO_STREAMS无缘无故调用了
/sites/1
上的DELETE方法(非常糟糕)
我不知道为什么会发生这件事。
这是webrick输出的结果。您可以看到它也试图删除该网站。我不知道为什么...