Environment
- Ruby 3.0.3
- Rails 7.0.1
- Devise 4.8.1
Current behavior
With the default routing options, the url to get the form to sign_up is: resource/sign_up.
This returns a form which default action is to POST to resource.
In case of validation errors on this form, the url of the browser is then resource. If the user refreshes his browser, he get a 404 error.
Expected behavior
In case of validation errors, if the user refreshes, he should get the form from /resource/sign_up
Note:
The expected behavior is the correct one for the sign_in form. (Both get and post actions target /resource/sign_in)
This can be fixed for the sign_up form with:
module ActionDispatch::Routing
class Mapper
def devise_registration(mapping, controllers) #:nodoc:
path_names = {
new: mapping.path_names[:sign_up],
edit: mapping.path_names[:edit],
cancel: mapping.path_names[:cancel]
}
options = {
only: [:edit, :update, :destroy],
path: mapping.path_names[:registration],
path_names: path_names,
controller: controllers[:registrations]
}
# force :create to be at same url than :new
resource :registration, options do
get :new, path: mapping.path_names[:sign_up], as: 'new'
post :create, path: mapping.path_names[:sign_up], as: 'create'
get :cancel
end
end
end
end
Environment
Current behavior
With the default routing options, the url to get the form to sign_up is:
resource/sign_up.This returns a form which default action is to POST to
resource.In case of validation errors on this form, the url of the browser is then
resource. If the user refreshes his browser, he get a 404 error.Expected behavior
In case of validation errors, if the user refreshes, he should get the form from
/resource/sign_upNote:
The expected behavior is the correct one for the sign_in form. (Both get and post actions target
/resource/sign_in)This can be fixed for the sign_up form with: