質問編集履歴
6
Github url 追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
|
2
2
|
予約完了画面に移行したい。
|
3
|
+
↓以下Gitソースコード
|
4
|
+
https://github.com/waszo/rsv_003/tree/develop
|
3
5
|
|
4
6
|
### 発生している問題・分からないこと
|
5
7
|
If room.image_roomが定義されていないと出ている問題
|
5
ndex は controller のdef index 追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
|
-
コード
|
3
|
-
```### 実現したいこと
|
4
2
|
予約完了画面に移行したい。
|
5
3
|
|
6
4
|
### 発生している問題・分からないこと
|
@@ -64,6 +62,15 @@
|
|
64
62
|
</tbody>
|
65
63
|
</table>
|
66
64
|
```
|
65
|
+
```ここに言語を入力
|
66
|
+
class ReservationsController < ApplicationController
|
67
|
+
def index
|
68
|
+
@reservations = Reservation.includes(:room, :user).all
|
69
|
+
# @reservations = Reservation.all
|
70
|
+
|
71
|
+
end
|
72
|
+
```### 実現したいこと
|
73
|
+
|
67
74
|
以下エラーメッセージになります。
|
68
75
|
Started GET "/reservations/index" for ::1 at 2024-08-20 21:01:30 +0900
|
69
76
|
Processing by ReservationsController#index as HTML
|
4
修正2
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
コード
|
1
|
-
### 実現したいこと
|
3
|
+
```### 実現したいこと
|
2
4
|
予約完了画面に移行したい。
|
3
5
|
|
4
6
|
### 発生している問題・分からないこと
|
@@ -12,7 +14,7 @@
|
|
12
14
|
### 該当のソースコード
|
13
15
|
_以下ソースコード_
|
14
16
|
Reservations#index
|
15
|
-
|
17
|
+
```
|
16
18
|
<h2>予約済み一覧</h2>
|
17
19
|
|
18
20
|
<table class="table">
|
@@ -61,6 +63,7 @@
|
|
61
63
|
<% end %>
|
62
64
|
</tbody>
|
63
65
|
</table>
|
66
|
+
```
|
64
67
|
以下エラーメッセージになります。
|
65
68
|
Started GET "/reservations/index" for ::1 at 2024-08-20 21:01:30 +0900
|
66
69
|
Processing by ReservationsController#index as HTML
|
3
書式改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,54 +12,55 @@
|
|
12
12
|
### 該当のソースコード
|
13
13
|
_以下ソースコード_
|
14
14
|
Reservations#index
|
15
|
+
|
15
|
-
h2>予約済み一覧</h2>
|
16
|
+
<h2>予約済み一覧</h2>
|
16
17
|
|
17
18
|
<table class="table">
|
18
|
-
<thead>
|
19
|
+
<thead>
|
19
|
-
<tr>
|
20
|
+
<tr>
|
20
|
-
<th>画像</th>
|
21
|
+
<th>画像</th>
|
21
|
-
<th>施設名</th>
|
22
|
+
<th>施設名</th>
|
22
|
-
<th>紹介文</th>
|
23
|
+
<th>紹介文</th>
|
23
|
-
<th>合計料金</th>
|
24
|
+
<th>合計料金</th>
|
24
|
-
<th>チェックイン</th>
|
25
|
+
<th>チェックイン</th>
|
25
|
-
<th>チェックアウト</th>
|
26
|
+
<th>チェックアウト</th>
|
26
|
-
<th>予約確定日時</th>
|
27
|
+
<th>予約確定日時</th>
|
27
|
-
</tr>
|
28
|
+
</tr>
|
28
|
-
</thead>
|
29
|
+
</thead>
|
29
|
-
<tbody>
|
30
|
-
<% @reservations.each do |reservation| %>
|
31
|
-
<tr>
|
32
|
-
<td>
|
33
|
-
<% room = reservation.room %>
|
34
|
-
<% if room.image_room? %>
|
35
|
-
<%= image_tag room.image_room.url, size: '80x80' %>
|
36
|
-
<% else %>
|
37
|
-
<%= image_tag 'defolt_room_image.png', size: '80x80' %>
|
38
|
-
<% end %>
|
39
|
-
</td>
|
40
|
-
<td><%= room.name %></td>
|
41
|
-
<td><%= room.description %>
|
42
|
-
<td><%= (room.price * reservation.number_of_people * (reservation.finish_date - reservation.start_date)).to_i %> 円</td>
|
43
|
-
<td><%= reservation.start_date.strftime("%Y/%m/%d") %></td>
|
44
|
-
<td><%= reservation.finish_date.strftime("%Y/%m/%d") %></td>
|
45
30
|
|
31
|
+
<tbody>
|
32
|
+
<% @reservations.each do |reservation| %>
|
33
|
+
<tr>
|
34
|
+
<td>
|
35
|
+
<% room = reservation.room %>
|
36
|
+
<% if room.image_room? %>
|
37
|
+
<%= image_tag room.image_room.url, size: '80x80' %>
|
38
|
+
<% else %>
|
39
|
+
<%= image_tag 'defolt_room_image.png', size: '80x80' %>
|
40
|
+
<% end %>
|
41
|
+
</td>
|
42
|
+
<td><%= room.name %></td>
|
43
|
+
<td><%= room.description %>
|
44
|
+
<td><%= (room.price * reservation.number_of_people * (reservation.finish_date - reservation.start_date)).to_i %> 円</td>
|
45
|
+
<td><%= reservation.start_date.strftime("%Y/%m/%d") %></td>
|
46
|
+
<td><%= reservation.finish_date.strftime("%Y/%m/%d") %></td>
|
47
|
+
|
46
|
-
<td><%= reservation.created_at.strftime("%Y/%m/%d %H:%M") %></td>
|
48
|
+
<td><%= reservation.created_at.strftime("%Y/%m/%d %H:%M") %></td>
|
47
|
-
<td class="dropdown">
|
49
|
+
<td class="dropdown">
|
48
|
-
<button class="btn btn-Link dropdown-toggle" type="button" id="dropdownMenuButton<%= room.id %>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
50
|
+
<button class="btn btn-Link dropdown-toggle" type="button" id="dropdownMenuButton<%= room.id %>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
49
|
-
<img alt="3点メニューアイコン" src="https://rails-02-sample.herokuapp.com/assets/icons/three-dot-menu-0c042cde96cc73e058e97d09a24944eb2914eb8c152d418dc6fc6964251fdaa2.svg" class="dropdown-image">
|
51
|
+
<img alt="3点メニューアイコン" src="https://rails-02-sample.herokuapp.com/assets/icons/three-dot-menu-0c042cde96cc73e058e97d09a24944eb2914eb8c152d418dc6fc6964251fdaa2.svg" class="dropdown-image">
|
50
|
-
</button>
|
52
|
+
</button>
|
51
|
-
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton<%= room.id %>">
|
53
|
+
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton<%= room.id %>">
|
52
|
-
|
54
|
+
|
53
|
-
<a class="dropdown-item" href="<%= edit_reservation_path(reservation) %>">編集</a>
|
55
|
+
<a class="dropdown-item" href="<%= edit_reservation_path(reservation) %>">編集</a>
|
54
|
-
<a class="dropdown-item" href="<%= reservation_path(reservation) %>" data-method="delete" data-confirm="本当に削除しますか?">削除</a>
|
56
|
+
<a class="dropdown-item" href="<%= reservation_path(reservation) %>" data-method="delete" data-confirm="本当に削除しますか?">削除</a>
|
55
|
-
</div>
|
57
|
+
</div>
|
56
|
-
</td>
|
58
|
+
</td>
|
57
|
-
|
59
|
+
|
58
|
-
</tr>
|
60
|
+
</tr>
|
59
|
-
<% end %>
|
61
|
+
<% end %>
|
60
|
-
</tbody>
|
62
|
+
</tbody>
|
61
63
|
</table>
|
62
|
-
|
63
64
|
以下エラーメッセージになります。
|
64
65
|
Started GET "/reservations/index" for ::1 at 2024-08-20 21:01:30 +0900
|
65
66
|
Processing by ReservationsController#index as HTML
|
2
該当のソースコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,6 +10,86 @@
|
|
10
10
|
```
|
11
11
|
|
12
12
|
### 該当のソースコード
|
13
|
+
_以下ソースコード_
|
14
|
+
Reservations#index
|
15
|
+
h2>予約済み一覧</h2>
|
16
|
+
|
17
|
+
<table class="table">
|
18
|
+
<thead>
|
19
|
+
<tr>
|
20
|
+
<th>画像</th>
|
21
|
+
<th>施設名</th>
|
22
|
+
<th>紹介文</th>
|
23
|
+
<th>合計料金</th>
|
24
|
+
<th>チェックイン</th>
|
25
|
+
<th>チェックアウト</th>
|
26
|
+
<th>予約確定日時</th>
|
27
|
+
</tr>
|
28
|
+
</thead>
|
29
|
+
<tbody>
|
30
|
+
<% @reservations.each do |reservation| %>
|
31
|
+
<tr>
|
32
|
+
<td>
|
33
|
+
<% room = reservation.room %>
|
34
|
+
<% if room.image_room? %>
|
35
|
+
<%= image_tag room.image_room.url, size: '80x80' %>
|
36
|
+
<% else %>
|
37
|
+
<%= image_tag 'defolt_room_image.png', size: '80x80' %>
|
38
|
+
<% end %>
|
39
|
+
</td>
|
40
|
+
<td><%= room.name %></td>
|
41
|
+
<td><%= room.description %>
|
42
|
+
<td><%= (room.price * reservation.number_of_people * (reservation.finish_date - reservation.start_date)).to_i %> 円</td>
|
43
|
+
<td><%= reservation.start_date.strftime("%Y/%m/%d") %></td>
|
44
|
+
<td><%= reservation.finish_date.strftime("%Y/%m/%d") %></td>
|
45
|
+
|
46
|
+
<td><%= reservation.created_at.strftime("%Y/%m/%d %H:%M") %></td>
|
47
|
+
<td class="dropdown">
|
48
|
+
<button class="btn btn-Link dropdown-toggle" type="button" id="dropdownMenuButton<%= room.id %>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
49
|
+
<img alt="3点メニューアイコン" src="https://rails-02-sample.herokuapp.com/assets/icons/three-dot-menu-0c042cde96cc73e058e97d09a24944eb2914eb8c152d418dc6fc6964251fdaa2.svg" class="dropdown-image">
|
50
|
+
</button>
|
51
|
+
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton<%= room.id %>">
|
52
|
+
|
53
|
+
<a class="dropdown-item" href="<%= edit_reservation_path(reservation) %>">編集</a>
|
54
|
+
<a class="dropdown-item" href="<%= reservation_path(reservation) %>" data-method="delete" data-confirm="本当に削除しますか?">削除</a>
|
55
|
+
</div>
|
56
|
+
</td>
|
57
|
+
|
58
|
+
</tr>
|
59
|
+
<% end %>
|
60
|
+
</tbody>
|
61
|
+
</table>
|
62
|
+
|
63
|
+
以下エラーメッセージになります。
|
64
|
+
Started GET "/reservations/index" for ::1 at 2024-08-20 21:01:30 +0900
|
65
|
+
Processing by ReservationsController#index as HTML
|
66
|
+
(0.0ms) SELECT sqlite_version(*)
|
67
|
+
↳ app/controllers/application_controller.rb:12:in `set_search'
|
68
|
+
Rendering layout layouts/application.html.erb
|
69
|
+
Rendering reservations/index.html.erb within layouts/application
|
70
|
+
Reservation Load (0.8ms) SELECT "reservations".* FROM "reservations"
|
71
|
+
↳ app/views/reservations/index.html.erb:17
|
72
|
+
Room Load (0.0ms) SELECT "rooms".* FROM "rooms" WHERE "rooms"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
|
73
|
+
↳ app/views/reservations/index.html.erb:20
|
74
|
+
Rendered reservations/index.html.erb within layouts/application (Duration: 5.2ms | Allocations: 7652)
|
75
|
+
Rendered layout layouts/application.html.erb (Duration: 5.3ms | Allocations: 7730)
|
76
|
+
Completed 500 Internal Server Error in 11ms (ActiveRecord: 1.1ms | Allocations: 12925)
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
ActionView::Template::Error (undefined method `image_room?' for nil:NilClass):
|
81
|
+
18: <tr>
|
82
|
+
19: <td>
|
83
|
+
20: <% room = reservation.room %>
|
84
|
+
21: <% if room.image_room? %>
|
85
|
+
22: <%= image_tag room.image_room.url, size: '80x80' %>
|
86
|
+
23: <% else %>
|
87
|
+
24: <%= image_tag 'defolt_room_image.png', size: '80x80' %>
|
88
|
+
|
89
|
+
app/views/reservations/index.html.erb:21
|
90
|
+
app/views/reservations/index.html.erb:17
|
91
|
+
|
92
|
+
|
13
93
|
|
14
94
|
```
|
15
95
|
特になし
|
1
追加のGit
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,4 +26,5 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
### 補足
|
29
|
+
https://github.com/waszo/rsv_003/tree/develop
|
29
30
|
![イメージ説明](https://ddjkaamml8q8x.cloudfront.net/questions/2024-08-19/7b0cd3c2-a3e7-47c6-b6e7-cc2d1d042501.png)
|