実際、私たちは問題の解決のためにdeviseのソースコードを見ることができ、簡単です。コードが示すように
devise-3.4.1 $ vim app/controllers/devise/registrations_controller.rb
# POST /resource
def create
build_resource(sign_up_params)
resource_saved = resource.save
yield resource if block_given?
if resource_saved
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
@validatable = devise_mapping.validatable?
if @validatable
@minimum_password_length = resource_class.password_length.min
end
respond_with resource
end
end
:
if resource.active_for_authentication?
...
respond_with resource, location: after_sign_up_path_for(resource)
else
...
respond_with resource, location: after_inactive_sign_up_path_for(resource)
は私の課題であったこと、ありがとうございます。 – MicFin
ありがとう! D – marman
これは、ユーザーがログインに対して非アクティブなすべての場合に適用されることに注意してください。たとえば、 'active_for_authentication?をオーバーライドした場合などです。これは、ユーザーがアカウントを確認するまでログインしていない確認可能なケース。 –