質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

0回答

766閲覧

railsでログインできない

yukitodesu

総合スコア1

Cloud9

Cloud9は、クラウドからのプログラミングが可能になるWebサービス。IDEとしての機能が搭載されており、GitHubやHerokuなど他ツールとの連携も可能です。ブラウザ上で動くため、デバイスに関係なく開発環境を準備できます。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2021/06/15 01:09

railsでアプリケーションを作っているのでうすが、ログインすることができません。beybugでデータの中身を見たときは、

def
after_sign_in_path_for(resource)
case resource
when User
byebug
public_users_mypage_path
when Admin
admins_users_path
end
end

のコードが機能していませんでした。
どう解決すれば良いかアドバイスいただきたいです。

application.controller.rb

class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? def after_sign_in_path_for(resource) case resource when User byebug public_users_mypage_path when Admin admins_users_path end end def after_sign_out_path_for(resource_or_scope) if resource_or_scope == :admin_admin_user new_admin_user_registaration_path else root_path end end protected def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :first_name_kana, :last_name_kana, :phone_number, :is_active ,:image,:instagram_id, :introduction]) end end

routes.rb

Rails.application.routes.draw do root :to => 'public/homes#top' devise_for :users, controllers: { sessions: 'user/sessions', registrations: 'user/registrations' } namespace :public, path: "" do get 'users/mypage' => 'users#mypage' get'posts_all' => 'posts#posts_all' post'posts_all' => 'posts#posts_all' get 'search_all' => 'users#search_all' post 'search_all' => 'users#search_all' resources :users, only: [:edit, :update ,:index , :show] do resources :posts, only: [:index,:create,:show,:edit,:update, :destroy] do delete 'post_item_destroy' post 'post_item_create' resources :post_items, only: [:destroy, :index] resources :likes, only: [:create, :destroy, :index] resources :comments, only: [:create, :destroy] end get 'unsubscribe/:id' => 'users#unsubscribe', as: 'confirm_unsubscribe' patch 'withdraw/:id' => 'users#withdraw', as: 'withdraw_user' put 'withdraw/:id' => 'users#withdraw' get 'users/tags' => 'posts#post_tags' resource :relationships, only: [:create, :destroy] get 'followings' => 'relationships#followings', as: 'followings' get 'followers' => 'relationships#followers', as: 'followers' resource :favorites, only: [:create, :destroy] end resources :messages, only: [:create] resources :rooms, only: [:create,:show, :index] end devise_for :admins, controllers: { sessions: 'user/sessions', registrations: 'user/registrations' } namespace :admins do resources :users resources :posts patch 'post_item_update' => 'posts#post_item_update' resources :tags, only: [:index] end end

回答よろしくお願いします

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

winterboum

2021/06/15 12:30

logみせてください
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問