Update default scaffold templates to set 303 (See Other) as status code on redirect for the update action
XHR requests other than GET or POST have issues when using 302 (e.g browsers trying to follow the redirect using the original request method resulting in double PATCH/PUT) This should be reverted when / if https://github.com/rails/rails/pull/45393 is merged
This commit is contained in:
parent
8a158ed5e3
commit
5ed37b35d6
@ -1,3 +1,10 @@
|
||||
* Update default scaffold templates to set 303 (See Other) as status code
|
||||
on redirect for the update action for XHR requests other than GET or POST
|
||||
to avoid issues (e.g browsers trying to follow the redirect using the
|
||||
original request method resulting in double PATCH/PUT)
|
||||
|
||||
*Guillermo Iguaran*
|
||||
|
||||
* The new `config.autoload_lib_once` is similar to `config.autoload_lib`,
|
||||
except that it adds `lib` to `config.autoload_once_paths` instead.
|
||||
|
||||
|
@ -34,7 +34,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
||||
# PATCH/PUT <%= route_url %>/1
|
||||
def update
|
||||
if @<%= orm_instance.update("#{singular_table_name}_params") %>
|
||||
redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %>
|
||||
redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %>, status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
|
@ -41,6 +41,7 @@ def test_controller_skeleton_is_created
|
||||
|
||||
assert_instance_method :update, content do |m|
|
||||
assert_match(/@user\.update\(user_params\)/, m)
|
||||
assert_match(/status: :see_other/, m)
|
||||
end
|
||||
|
||||
assert_instance_method :destroy, content do |m|
|
||||
|
Loading…
Reference in New Issue
Block a user