質問編集履歴
3
質問のコード修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,10 +10,9 @@
|
|
10
10
|
```
|
11
11
|
|
12
12
|
### 該当のソースコード
|
13
|
-
!更新10/0
|
13
|
+
!更新10/08 0:30
|
14
14
|
```plans_controller.rb
|
15
|
-
@rooms = Room.all
|
16
|
-
@room = Room.
|
15
|
+
@room = Room.all.find_by(plan_id: @plan.id)
|
17
16
|
```
|
18
17
|
!更新10/07 21:55
|
19
18
|
```views/plans/show.html.erb
|
2
質問のコードの更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -3,44 +3,22 @@
|
|
3
3
|
メソッドが見つからないのはなぜでしょうか?
|
4
4
|
|
5
5
|
### 発生している問題・エラーメッセージ
|
6
|
-
|
6
|
+
!更新10/07 21:55
|
7
7
|
```
|
8
|
-
|
8
|
+
NoMethodError at /plans/18
|
9
|
+
undefined method `plan_id' for #<ActiveRecord::Relation [#<Room id: 1, room_name: "aaaaaaaaaaaaaa", created_at: "2022-10-07 13:07:47.438365000 +0900", updated_at: "2022-10-07 13:07:47.438365000 +0900", plan_id: 18>]>
|
9
10
|
```
|
10
11
|
|
11
12
|
### 該当のソースコード
|
12
|
-
|
13
|
+
!更新10/07 21:55
|
13
14
|
```plans_controller.rb
|
14
|
-
def show
|
15
|
-
if user_signed_in?
|
16
|
-
@room = Room.all.select(:id,:room_name,:plan_id) ←該当箇所
|
17
|
-
@plan=Plan.find(params[:id])
|
18
|
-
@currentUserEntry=Entry.where(user_id: current_user.id)
|
19
|
-
@userEntry=Entry.where(user_id: @plan.user_id)
|
20
|
-
unless @plan.user.id == current_user.id
|
21
|
-
@currentUserEntry.each do |cu|
|
22
|
-
@userEntry.each do |u|
|
23
|
-
if cu.room_id == u.room_id then
|
24
|
-
@isRoom = true
|
25
|
-
@roomId = cu.room_id
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
if @isRoom
|
30
|
-
else
|
31
|
-
|
15
|
+
@rooms = Room.all
|
16
|
+
@room = Room.where(plan_id: @rooms.plan_id)
|
17
|
+
```
|
18
|
+
!更新10/07 21:55
|
19
|
+
```views/plans/show.html.erb
|
20
|
+
<% if @plan.id == @room %>
|
21
|
+
<p class="user-show-room"><a href="/rooms/<%= @roomId %>"class="btn btn-primary btn-lg">メッセージ</a>
|
32
|
-
|
22
|
+
<% end %>
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
23
|
```
|
38
24
|
|
39
|
-
```views/plans/show.html.erb
|
40
|
-
<% if @plan.id == @room.plan_id %> ←該当箇所
|
41
|
-
<% if @isRoom == true %>
|
42
|
-
<p class="user-show-room"><a href="/rooms/<%= @roomId %>"class="btn btn-primary btn-lg">メッセージ</a>
|
43
|
-
<% end %>
|
44
|
-
<% else %>
|
45
|
-
```
|
46
|
-
|
1
質問の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
```plans_controller.rb
|
14
14
|
def show
|
15
15
|
if user_signed_in?
|
16
|
-
@room = Room.all.select(:id,:room_name,:plan_id)
|
16
|
+
@room = Room.all.select(:id,:room_name,:plan_id) ←該当箇所
|
17
17
|
@plan=Plan.find(params[:id])
|
18
18
|
@currentUserEntry=Entry.where(user_id: current_user.id)
|
19
19
|
@userEntry=Entry.where(user_id: @plan.user_id)
|
@@ -37,7 +37,7 @@
|
|
37
37
|
```
|
38
38
|
|
39
39
|
```views/plans/show.html.erb
|
40
|
-
<% if @plan.id == @room.plan_id %>
|
40
|
+
<% if @plan.id == @room.plan_id %> ←該当箇所
|
41
41
|
<% if @isRoom == true %>
|
42
42
|
<p class="user-show-room"><a href="/rooms/<%= @roomId %>"class="btn btn-primary btn-lg">メッセージ</a>
|
43
43
|
<% end %>
|