1
1

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.

【解決!!】ActiveRecord::RecordNotFound (Couldn't find User without an ID)

Last updated at Posted at 2020-11-01

【エラー内容】

スクリーンショット 2020-11-01 14.16.09.png

ActiveRecord::RecordNotFound (Couldn't find User without an ID)
「IDないで!!」っていうエラー。

〜エラー出るまでの経緯〜
1:ググりながらフォロー機能完成🙋‍♀️
2:フォローボタンSubmitFontAwesome(link_to)に変更してみよう💡
3:今回のエラー発生💥
4:DBにはちゃんとデータがあることを確認👀
5:機能は動いてるのに、値が渡せてないってこと???🤔なんで????🤢

めちゃくちゃ悩まされた結果、無事に解決したのですが

なんと

【結論】

そもそもフォロー機能ができていなかったw

え??どういうこと??😂

【原因】

元々Submitでフォロー機能を実装。(この時はきちんと機能が生きていた

SubmitからFontAwesome(link_toPathの受け渡し)に変更。(この時点で機能が**お亡くなりになっていた…**チーン😭)

【解決策】

1.DBテーブルを空にする。
2.フォローアクション実行
3.再度DB確認→データが空=結局フォロー機能できていなかったことに気づくw

terminal
mysql> delete from relationships;
Query OK, 1 row affected (0.02 sec)
terminal
mysql> select *from relationships;
Empty set (0.00 sec)

【スランプに陥った原因】

1.DBでフォローデータがあるか確認。
2.結果:ある。(←実はSubmitで実行した時のデータだった。)
3.フォロー機能は実装できていると解釈。(←ここがスランプの元凶!!!)

terminal
mysql> select *from relationships;
+----+---------+-----------+----------------------------+----------------------------+
| id | user_id | follow_id | created_at                 | updated_at                 |
+----+---------+-----------+----------------------------+----------------------------+
| 16 |       1 |         2 | 2020-10-31 07:34:37.912469 | 2020-10-31 07:34:37.912469 |
+----+---------+-----------+----------------------------+----------------------------+
1 row in set (0.01 sec)

【反省】

DBを確認する大切さ…涙ちょちょぎれるくらいに身に染みました…(´;ω;`)

本日参加させていただいた、もくもく会の主催者様が一生懸命このエラーと向き合ってくださり

無事、このように解決いたしました。。心から感謝いたします。。精進します。。。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?