I am working on a checkout process in Rails. Currently a reload of the Page, where I have routed to through a redirect_to after completing the checkout results in a new post request. This happens when using the Safari browser.
After posting the order in the checkout process I call
def create
.
.
### Reset session after order has been submitted
session[:order_step] = session[:order_params] = nil
redirect_to controller: :shops, action: :index
end
and redirect to the shop index page.
When I reload this shop index page, the browser tries a post request. For now I changed my shop index route to match posts and gets, in order to not raise an exception, and everything appears to be working, but I would like to know, why a new post request is issued after the redirect and if I can get to a situation, where a reload of the shop index page after the redirect from the order create action results in a normal get request.
This is a summary of my process:
.
.
Redirected to http://localhost:3000/shop
Completed 303 See Other in 2168ms (ActiveRecord: 18.2ms | Allocations: 73087)
Started GET "/shop" for ::1 at 2022-06-21 12:53:52 +0200
Processing by ShopsController#index as TURBO_STREAM
.
.
Completed 200 OK in 39ms (Views: 34.5ms | ActiveRecord: 2.4ms | Allocations: 21182)
Started POST "/shop" for ::1 at 2022-06-21 12:56:09 +0200
Processing by ShopsController#index as HTML
.
.
Completed 200 OK in 69ms (Views: 20.7ms | ActiveRecord: 43.4ms | Allocations: 20816)
When I try to reload through the browser reload button, the browser tries to send a post request.
When I reload the page by initiating a load through the url field, the browser sends a get request. How can I get to the latter immediately from my create action?
Thank you in advance.
Addition
It appears that this only happens in Safari. In Chrome and Firefox it just issues a get request after reloads. What can I do?