申し訳ありませんが、最初はサインアップ後にサインインではなく意味があると思いました。したがって、以下のダウンは、サインアップ後にユーザーを誘導する方法について機能し、サインインのために行う必要があるのは、カスタムDevise::FailureAppを作成することです。
wikiページを参照してください:https ://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-when-the-user-can-not-be-authenticated
次に、 https : //github.com/plataformatec/devise/blob/master/lib/devise/failure_app.rbのカスタムFailureApp上書きredirect_url
メソッド内で:
def redirect_url
if warden_message == :unconfirmed
custom_redirect_path
else
super
end
end
サインアップ後のカスタムリダイレクトの場合:
after_inactive_sign_up_path_for
これを実現するために上書きできるRegistrationsController内のコントローラーメソッドがあります。
ルートの最初に、カスタムコントローラを使用するように指定する必要があります。
config/routes.rb
:
devise_for :users, :controllers => { :registrations => "users/registrations" }
次に、メソッドを上書きするために、通常のコントローラーから継承するカスタムコントローラーを作成します。
app/controllers/users/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController
protected
def after_inactive_sign_up_path_for(resource)
signed_up_path
end
end
この場合、私のアプリの場合、私のDeviseモデルはUserであるため、モデルの名前が異なる場合は、その名前空間を変更することをお勧めします。ユーザーをにリダイレクトしたかったのsigned_up_path
ですが、それを希望のパスに変更できます。