Redirect_to 与 post 参数

Redirect_to with post params

我写了这个重定向:

redirect_to list_order_submit_path(:provider_id => @cart_item.product.provider.id)

但是这会显示 URL 中的 Provider_id:

localhost:3000/order/list?provider_id=1

我如何传递不在 URL 中的变量,或者如何将其传递给 post 参数?

我会引用 this SO answer 的开头供以后的观众使用:

You can't do a redirect and send POST data at the same time in the HTTP spec.

你不应该这样做。您想要的是 GET 请愿书,因为您列出的是元素而不是修改它们。

因此在 header 中传递参数是正确的,也是最佳实践。