class User < ApplicationRecord # Include default devise modules. Others available are: # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable # あるユーザーがフォローしている他ユーザーとのアソシエーション(フォロー) has_many :relationships, foreign_key: 'user_id', dependent: :destroy has_many :followings, through: :relationship