質問編集履歴
3
返信のため
test
CHANGED
File without changes
|
test
CHANGED
@@ -355,3 +355,25 @@
|
|
355
355
|
|
356
356
|
|
357
357
|
```
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
2019.12.3 12:04追記
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
エラー画面
|
370
|
+
|
371
|
+
![イメージ説明](87a5511bf577422cf5e46cc6892004d8.png)
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
フォームの内容が反映された詳細ページ
|
378
|
+
|
379
|
+
![イメージ説明](0b9cc7435c09663af0f355adc303bd5d.png)
|
2
返信のため
test
CHANGED
File without changes
|
test
CHANGED
@@ -317,3 +317,41 @@
|
|
317
317
|
|
318
318
|
|
319
319
|
```
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
2019.12.2 20:20追記
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
編集後new.html.erb
|
330
|
+
|
331
|
+
```html
|
332
|
+
|
333
|
+
<% @page_title = "新規情報の追加" %>
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
<h1><%= @page_title %></h1>
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
<td><%= link_to "詳細へ戻る", @cow %></td>
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
<%= form_for @treat do |form| %>
|
346
|
+
|
347
|
+
<%= form.hidden_field :cow_id %>
|
348
|
+
|
349
|
+
<%= render "form", form: form %>
|
350
|
+
|
351
|
+
<div><%= form.submit %></div>
|
352
|
+
|
353
|
+
<% end %>
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
```
|
1
返信のため
test
CHANGED
File without changes
|
test
CHANGED
@@ -269,3 +269,51 @@
|
|
269
269
|
|
270
270
|
|
271
271
|
よろしくお願いいたします。
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
2019.12.1 15:33追記
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
```ruby
|
284
|
+
|
285
|
+
class TreatmentsController < ApplicationController
|
286
|
+
|
287
|
+
def new
|
288
|
+
|
289
|
+
@treat = Treatment.new(posted_at: Date.new(2010,1,1))
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
def create
|
296
|
+
|
297
|
+
@treat = Treatment.new(params.require(:treatment).permit(:posted_at, :content, :detail, :cow_id))
|
298
|
+
|
299
|
+
if @treat.save
|
300
|
+
|
301
|
+
redirect_to @cow, notice: "追加しました。"
|
302
|
+
|
303
|
+
render template:'cows/show'
|
304
|
+
|
305
|
+
else
|
306
|
+
|
307
|
+
render "new"
|
308
|
+
|
309
|
+
end
|
310
|
+
|
311
|
+
end
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
end
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
```
|