【发布时间】:2026-01-27 22:05:02
【问题描述】:
我在“显示”视图上有一个 Rails 表单,看起来像:
<%= form_with(url: "/relative-path-to-index-view", method: "post") do |f| %>
<%= f.submit "Submit" %>
<% end %>
负责处理表单提交的控制器的create 操作如下所示:
def create
redirect_to action: "index", status: :see_other
end
当我提交表单时,我在网络选项卡中看到它发出了 POST 请求,收到了 303 :see_other 响应,然后对 index 操作发出了 GET 请求。但是,最终用户在浏览器中看不到任何重定向。关于为什么的任何想法?
【问题讨论】:
标签: ruby-on-rails forms redirect