質問編集履歴
1
質問がわかりづらかったので修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,9 +8,11 @@
|
|
8
8
|
|
9
9
|
content一覧ページから特定の(content/:id)などのページを開きその画面でコンテンツに紐づいたmessageを作成し同じページに表示したいです。
|
10
10
|
|
11
|
-
その際のcontrollerの記述方法なのですが
|
11
|
+
その際のcontrollerの記述方法なのですが下記 記述です。
|
12
12
|
|
13
13
|
|
14
|
+
|
15
|
+
**controller**
|
14
16
|
|
15
17
|
|
16
18
|
|
@@ -18,17 +20,13 @@
|
|
18
20
|
|
19
21
|
before_action :logged_in_user, only: [:show, :create]
|
20
22
|
|
21
|
-
before_action :show_set, only: [:show, :create ]
|
22
|
-
|
23
|
-
before_action :open_show, only: [:show ]
|
24
|
-
|
25
|
-
|
26
|
-
|
27
23
|
|
28
24
|
|
29
25
|
def show
|
30
26
|
|
31
|
-
@message =
|
27
|
+
@message = Message.new
|
28
|
+
|
29
|
+
@content = Content.find(params[:id])
|
32
30
|
|
33
31
|
end
|
34
32
|
|
@@ -54,33 +52,7 @@
|
|
54
52
|
|
55
53
|
|
56
54
|
|
57
|
-
def show_content
|
58
|
-
|
59
|
-
content = Content.find_by(params[:id])
|
60
|
-
|
61
|
-
@message = content.messages
|
62
|
-
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
|
67
55
|
private
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
def show_set
|
72
|
-
|
73
|
-
@message = Message.new
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
def open_show
|
80
|
-
|
81
|
-
@content = Content.find(params[:id])
|
82
|
-
|
83
|
-
end
|
84
56
|
|
85
57
|
|
86
58
|
|
@@ -94,7 +66,7 @@
|
|
94
66
|
|
95
67
|
|
96
68
|
|
97
|
-
|
69
|
+
**view**
|
98
70
|
|
99
71
|
|
100
72
|
|
@@ -120,18 +92,24 @@
|
|
120
92
|
|
121
93
|
|
122
94
|
|
123
|
-
|
95
|
+
**この下にcontent.messagesを出力したい**
|
124
96
|
|
125
97
|
|
126
98
|
|
127
|
-
|
99
|
+
@message.each do |msg|
|
128
100
|
|
129
|
-
|
101
|
+
....
|
130
102
|
|
131
|
-
|
103
|
+
....
|
104
|
+
|
105
|
+
end
|
132
106
|
|
133
107
|
|
134
108
|
|
109
|
+
上記のようにしたいのですがcontrollerでのデータの取得ができないです。(記述方法が分からない)
|
110
|
+
|
135
|
-
|
111
|
+
もしお分かりになる方がいれば、実装可能なのかともしわかれば記述方法も教えていただきたいです。
|
112
|
+
|
113
|
+
|
136
114
|
|
137
115
|
よろしくお願いいたします。
|