LoginSignup
0
0

More than 1 year has passed since last update.

お気に入り機能already_favorited?エラー

Last updated at Posted at 2023-03-26

お気に入り機能エラー

お気に入り機能を付けていこうとしたら
エラーが出てきた!調べてみる。。

image.png

undefined method `already_favorited?'
とエラーが出ているalready_favorited?がダメらしい

models/user.rb
# すでにいいねしているかを判定するメソッド
def already_favorited?(spot)
    self.favorites.exists?(spot_id: spot.id)
end

already_favorited?は、いいねしているかを判定するメソッド
これをuserのモデルに記述していなかったのでエラーが出ていました…:sweat_smile:

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