2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

新規登録後、ログイン後のリダイレクト先を変更する

Posted at

概要

新規登録後、ログイン後のリダイレクト先を変更する。

※デフォルトではリダイレクト先がroot_ptahとなっている。

前提

deviseをインストールし、新規登録、及びログイン機能が実装済み

バージョン

rubyのバージョン ruby-2.6.5
Railsのバージョン Rails:6.0.0

実装内容

app/controllers/application_controller.rbに以下を記述する。

app/controllers/application_controller.rb

省略

# 新規登録後のリダイレクト先の指定
def after_inactive_sign_up_path_for(resource)
    指定_path                 
end

# ログイン後のリダイレクト先の指定
def after_sign_in_path_for(resource)
    指定_path 
end

省略

*指定は、自身が指定したいパスを記述

以上です。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?