LoginSignup
3
3

More than 3 years have passed since last update.

【Rails】Nil location provided. Can't build URI.の対処法

Posted at

こんなエラー文が表示されました。

image.png

こちらを参考に解決しました。
https://simpledancer.hatenablog.com/entry/2019/05/19/Nil_location_provided__Can't_build_URI%E3%82%A8%E3%83%A9%E3%83%BC%E3%81%8C%E5%87%BA%E3%81%9F%E6%99%82%E3%81%AB%E3%82%84%E3%81%A3%E3%81%9F%E3%81%93%E3%81%A8

投稿したデータを全て削除すれば良いらしいです。

とりあえずターミナルでコンソールに入ります。

$ rails c

私の場合モデル名はGymのため、

>> Gym.all

をしたところ、次のように表示されました。

=> #<ActiveRecord::Relation [#<Gym id: 3, name: "ゴールドジム", content: "良い", user_id: 1, created_at: "2020-03-20 03:37:09", updated_at: "2020-03-20 03:37:09", picture: nil>, #<Gym id: 4, name: "ゴールドジム", content: "あああ", user_id: 1, created_at: "2020-03-20 04:22:44", updated_at: "2020-03-20 04:22:44", picture: nil>, #<Gym id: 5, name: "ああ", content: "ああ", user_id: 1, created_at: "2020-03-21 12:40:34", updated_at: "2020-03-21 12:40:34", picture: "スクリーンショット_2020-03-20_23.57.2657.png">]>

pictureカラムのnilが悪さをしてますので、削除します。

Gym.where(id:1..5).destroy_all;

これで、エラー部分が動くようになりました。

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