LoginSignup
0
0

More than 3 years have passed since last update.

[Rails]「×××_path」ってどう編集すればいいの?

Last updated at Posted at 2020-01-05

経緯

オリジナルアプリ作成に伴いログイン機能を実装しました。

その際、ログイン後にアクセスしたいページに遷移することができず、かなり時間をとられたので備忘録的に書き残します。

該当箇所

controrllers/application_controller.rb

class Users::SessionsController 
  def after_sign_in_path_for(resource)
    XXXX_path #ご自身のpath
  end

詰まった理由

・「×××_path」が何を表すのか分からなかった。

・「×××」に何を入れればいいか分からなかった。

分かったこと

・「×××_path」が何を表すのか分からなかった。
→ サインインした後に表示したいパス(URL)

・「×××」に何を入れればいいか分からなかった。
→ rails routesした際のPATHを入力
(※今回は赤線部分「bustersコントローラー」の「indexアクション」に紐づくViewをログイン後に表示したいので、赤戦部分のPATHを入力)

login1.png

解決策

controrllers/application_controller.rb

class Users::SessionsController 
  def after_sign_in_path_for(resource)
    busters_path #ご自身のpath
  end
0
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
0
0