質問編集履歴

4

ログ追加

2024/04/05 16:27

投稿

pag_jiro
pag_jiro

スコア10

test CHANGED
File without changes
test CHANGED
@@ -77,5 +77,33 @@
77
77
  created_at: Thu, 21 Mar 2024 19:48:53.763834000 JST +09:00,
78
78
  updated_at: Thu, 21 Mar 2024 19:48:53.763834000 JST +09:00>]
79
79
  ```
80
+ そしてエラーが発生しているapp/controllers/user/shops_controller.rb内のコードも下記に記載します。
81
+ ```
82
+ class User::ShopsController < ApplicationController
83
+
84
+ def accommodation
85
+ target_genre = Genre.find_by(name: "宿泊施設")
86
+ @shops = target_genre.shops
87
+ @revue = Revue.new
88
+ end
89
+
90
+ def shopping_mall
91
+ target_genre = Genre.find_by(name: "ショッピングモール")
92
+ @shops = target_genre.shops
93
+ @revue = Revue.new
94
+ end
95
+
96
+ def activity
97
+ target_genre = Genre.find_by(name: "アクティビティ")
98
+ @shops = target_genre.shops
99
+ @revue = Revue.new
100
+ end
101
+
102
+ def show
103
+ end
104
+
105
+ end
106
+
107
+ ```
80
108
  ログで出ているINFOの内容も分かりません。
81
109
  教えてほしいです。

3

ログ更新

2024/04/05 16:19

投稿

pag_jiro
pag_jiro

スコア10

test CHANGED
File without changes
test CHANGED
@@ -52,5 +52,30 @@
52
52
  [57dedbb7-8971-4bb0-9aa9-16ebd36df769]
53
53
  [57dedbb7-8971-4bb0-9aa9-16ebd36df769] app/controllers/user/shops_controller.rb:17:in `activity'
54
54
  ```
55
+ 上記ログにて、'shops'がnilだと言われていますが、Genreの中身を調べた時のログは下記になります。
56
+ ```
57
+ ec2-user:~/environment/* (main) $ rails c
58
+ Running via Spring preloader in process 17562
59
+ Loading development environment (Rails 6.1.7.6)
60
+ 3.1.2 :001 > Genre.all
61
+ (1.8ms) SELECT sqlite_version(*)
62
+ Genre Load (1.0ms) SELECT "genres".* FROM "genres"
63
+ =>
64
+ [#<Genre:0x00007f1fd9941c90
65
+ id: 1,
66
+ name: "宿泊施設",
67
+ created_at: Thu, 21 Mar 2024 19:48:53.728896000 JST +09:00,
68
+ updated_at: Thu, 21 Mar 2024 19:48:53.728896000 JST +09:00>,
69
+ #<Genre:0x00007f1fd9930c60
70
+ id: 2,
71
+ name: "ショッピングモール",
72
+ created_at: Thu, 21 Mar 2024 19:48:53.749879000 JST +09:00,
73
+ updated_at: Thu, 21 Mar 2024 19:48:53.749879000 JST +09:00>,
74
+ #<Genre:0x00007f1fd9930b98
75
+ id: 3,
76
+ name: "アクティビティ",
77
+ created_at: Thu, 21 Mar 2024 19:48:53.763834000 JST +09:00,
78
+ updated_at: Thu, 21 Mar 2024 19:48:53.763834000 JST +09:00>]
79
+ ```
55
80
  ログで出ているINFOの内容も分かりません。
56
81
  教えてほしいです。

2

ログ更新

2024/04/05 16:14

投稿

pag_jiro
pag_jiro

スコア10

test CHANGED
File without changes
test CHANGED
@@ -14,7 +14,7 @@
14
14
  特定のページに行くと下写真が表示されます。
15
15
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-04-04/37dd0f1b-cfb8-40a2-b348-756e5ebc97e7.png)
16
16
 
17
- ログの内容(更新:202404/06)
17
+ ログの内容(更新:2024/04/06)
18
18
  ```
19
19
  [ec2-user@ip-(プライベートIP) *]$ sudo tail -f log/production.log
20
20
  I, [2024-04-05T16:08:34.781147 #3565] INFO -- : [20281883-dea3-4002-9f2a-4666b6eeddc5] Started GET "/shops/accommodation" for 14.11.8.34 at 2024-04-05 16:08:34 +0000

1

ログ更新

2024/04/05 16:12

投稿

pag_jiro
pag_jiro

スコア10

test CHANGED
File without changes
test CHANGED
@@ -14,19 +14,43 @@
14
14
  特定のページに行くと下写真が表示されます。
15
15
  ![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-04-04/37dd0f1b-cfb8-40a2-b348-756e5ebc97e7.png)
16
16
 
17
- ログの内容
17
+ ログの内容(更新:2024年04/06)
18
18
  ```
19
- [ec2-user@ip-(プライートIP) *]$ sudo tail -f log/production.log
19
+ [ec2-user@ip-(プライートIP) *]$ sudo tail -f log/production.log
20
- I, [2024-04-04T14:11:23.758195 #3565] INFO -- : [dd903099-73d4-485c-a693-ed37066bcc3d] Started GET "/users/sign_up" for 14.11.8.34 at 2024-04-04 14:11:23 +0000
20
+ I, [2024-04-05T16:08:34.781147 #3565] INFO -- : [20281883-dea3-4002-9f2a-4666b6eeddc5] Started GET "/shops/accommodation" for 14.11.8.34 at 2024-04-05 16:08:34 +0000
21
- I, [2024-04-04T14:11:23.759248 #3565] INFO -- : [dd903099-73d4-485c-a693-ed37066bcc3d] Processing by User::RegistrationsController#new as HTML
21
+ I, [2024-04-05T16:08:34.781885 #3565] INFO -- : [20281883-dea3-4002-9f2a-4666b6eeddc5] Processing by User::ShopsController#accommodation as HTML
22
- I, [2024-04-04T14:11:23.787770 #3565] INFO -- : [dd903099-73d4-485c-a693-ed37066bcc3d] Rendered user/registrations/new.html.erb within layouts/application (Duration: 7.0ms | Allocations: 1673)
23
- I, [2024-04-04T14:11:23.789295 #3565] INFO -- : [dd903099-73d4-485c-a693-ed37066bcc3d] Rendered layout layouts/application.html.erb (Duration: 8.6ms | Allocations: 2695)
24
- I, [2024-04-04T14:11:23.789862 #3565] INFO -- : [dd903099-73d4-485c-a693-ed37066bcc3d] Completed 200 OK in 31ms (Views: 11.4ms | ActiveRecord: 7.7ms | Allocations: 9791)
22
+ I, [2024-04-05T16:08:34.807297 #3565] INFO -- : [20281883-dea3-4002-9f2a-4666b6eeddc5] Completed 500 Internal Server Error in 25ms (ActiveRecord: 10.6ms | Allocations: 1228)
23
+ F, [2024-04-05T16:08:34.808040 #3565] FATAL -- : [20281883-dea3-4002-9f2a-4666b6eeddc5]
24
+ [20281883-dea3-4002-9f2a-4666b6eeddc5] NoMethodError (undefined method `shops' for nil:NilClass
25
+
26
+ @shops = target_genre.shops
27
+ ^^^^^^):
28
+ [20281883-dea3-4002-9f2a-4666b6eeddc5]
29
+ [20281883-dea3-4002-9f2a-4666b6eeddc5] app/controllers/user/shops_controller.rb:5:in `accommodation'
30
+
31
+
25
- I, [2024-04-04T14:11:25.470599 #3565] INFO -- : [4e6bed0d-98d8-453e-b314-5bc16d2a42d0] Started GET "/users/sign_in" for 14.11.8.34 at 2024-04-04 14:11:25 +0000
32
+ I, [2024-04-05T16:09:23.258541 #3565] INFO -- : [9be6b26d-3d18-46d0-902f-b926c87848e2] Started GET "/shops/shopping_mall" for 14.11.8.34 at 2024-04-05 16:09:23 +0000
26
- I, [2024-04-04T14:11:25.471629 #3565] INFO -- : [4e6bed0d-98d8-453e-b314-5bc16d2a42d0] Processing by User::SessionsController#new as HTML
33
+ I, [2024-04-05T16:09:23.259280 #3565] INFO -- : [9be6b26d-3d18-46d0-902f-b926c87848e2] Processing by User::ShopsController#shopping_mall as HTML
27
- I, [2024-04-04T14:11:25.476984 #3565] INFO -- : [4e6bed0d-98d8-453e-b314-5bc16d2a42d0] Rendered user/sessions/new.html.erb within layouts/application (Duration: 1.9ms | Allocations: 739)
28
- I, [2024-04-04T14:11:25.478689 #3565] INFO -- : [4e6bed0d-98d8-453e-b314-5bc16d2a42d0] Rendered layout layouts/application.html.erb (Duration: 3.7ms | Allocations: 1769)
29
- I, [2024-04-04T14:11:25.478952 #3565] INFO -- : [4e6bed0d-98d8-453e-b314-5bc16d2a42d0] Completed 200 OK in 7ms (Views: 6.0ms | ActiveRecord: 0.0ms | Allocations: 3788)
34
+ I, [2024-04-05T16:09:23.262093 #3565] INFO -- : [9be6b26d-3d18-46d0-902f-b926c87848e2] Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.6ms | Allocations: 1052)
35
+ F, [2024-04-05T16:09:23.262978 #3565] FATAL -- : [9be6b26d-3d18-46d0-902f-b926c87848e2]
36
+ [9be6b26d-3d18-46d0-902f-b926c87848e2] NoMethodError (undefined method `shops' for nil:NilClass
37
+
38
+ @shops = target_genre.shops
39
+ ^^^^^^):
40
+ [9be6b26d-3d18-46d0-902f-b926c87848e2]
41
+ [9be6b26d-3d18-46d0-902f-b926c87848e2] app/controllers/user/shops_controller.rb:11:in `shopping_mall'
42
+
43
+
44
+ I, [2024-04-05T16:09:43.407816 #3565] INFO -- : [57dedbb7-8971-4bb0-9aa9-16ebd36df769] Started GET "/shops/activity" for 14.11.8.34 at 2024-04-05 16:09:43 +0000
45
+ I, [2024-04-05T16:09:43.408537 #3565] INFO -- : [57dedbb7-8971-4bb0-9aa9-16ebd36df769] Processing by User::ShopsController#activity as HTML
46
+ I, [2024-04-05T16:09:43.411274 #3565] INFO -- : [57dedbb7-8971-4bb0-9aa9-16ebd36df769] Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.5ms | Allocations: 1089)
47
+ F, [2024-04-05T16:09:43.411986 #3565] FATAL -- : [57dedbb7-8971-4bb0-9aa9-16ebd36df769]
48
+ [57dedbb7-8971-4bb0-9aa9-16ebd36df769] NoMethodError (undefined method `shops' for nil:NilClass
49
+
50
+ @shops = target_genre.shops
51
+ ^^^^^^):
52
+ [57dedbb7-8971-4bb0-9aa9-16ebd36df769]
53
+ [57dedbb7-8971-4bb0-9aa9-16ebd36df769] app/controllers/user/shops_controller.rb:17:in `activity'
30
54
  ```
31
55
  ログで出ているINFOの内容も分かりません。
32
56
  教えてほしいです。