質問編集履歴

2

コードの修正

2019/12/19 10:25

投稿

chihiro7215
chihiro7215

スコア11

test CHANGED
File without changes
test CHANGED
@@ -90,13 +90,15 @@
90
90
 
91
91
  <h1 class="text-center">Add Comment</h1>
92
92
 
93
- <%= form_with url: '/topics' + @topic_id.to_s + '/comments', local: true do |f| %>
93
+ <%= form_with url: '/topics/' + @topic_id.to_s + '/comments', local: true do |f| %>
94
94
 
95
95
  <div class="form-group">
96
96
 
97
97
  <%= f.label :message %>
98
98
 
99
99
  <%= f.text_area :message, class: 'form-control' %>
100
+
101
+ <%= f.hidden_field :topic_id, :value => params[:topic_id] %>
100
102
 
101
103
  </div>
102
104
 
@@ -118,7 +120,21 @@
118
120
 
119
121
  ```
120
122
 
123
+ app/views/topics/index.html.erb
121
124
 
125
+ ```
126
+
127
+ <%=link_to new_topic_comment_path(topic_id: topic.id), method: :get do %>
128
+
129
+ <%= image_tag 'icons/comment.png', class: 'topic-index-icon' %>
130
+
131
+ <% end %>
132
+
133
+ ```
134
+
135
+ おそらく
136
+
137
+ ```
122
138
 
123
139
  <%= form_with url: '/topics' + @topic_id.to_s + '/comments', local: true do |f| %>
124
140
 
@@ -134,7 +150,7 @@
134
150
 
135
151
  end
136
152
 
137
-
153
+ ```
138
154
 
139
155
  のどれが間違っているのか判断できない状況です。
140
156
 
@@ -142,11 +158,13 @@
142
158
 
143
159
  #試してみたこと
144
160
 
161
+ ```
162
+
145
163
  resources :topics do
146
164
 
147
- resources :comments
165
+ resources :comments
148
166
 
149
- end
167
+ end
150
168
 
151
169
 
152
170
 
@@ -154,9 +172,9 @@
154
172
 
155
173
 
156
174
 
157
- get 'comments/index'
175
+ get 'comments/index'
158
176
 
159
- post '/comments', to: 'comments#create'
177
+ post '/comments', to: 'comments#create'
160
178
 
161
179
 
162
180
 
@@ -164,7 +182,7 @@
164
182
 
165
183
 
166
184
 
167
- <%= form_with url: '/topics' + @topic_id.to_s + '/comments', local: true do |f| %>
185
+ <%= form_with url: '/topics/' + @topic_id.to_s + '/comments', local: true do |f| %>
168
186
 
169
187
 
170
188
 
@@ -173,3 +191,5 @@
173
191
 
174
192
 
175
193
  <%= form_with url: @topic_id.to_s + '/comments', local: true do |f| %>
194
+
195
+ ```

1

誤字

2019/12/19 10:25

投稿

chihiro7215
chihiro7215

スコア11

test CHANGED
File without changes
test CHANGED
File without changes