質問編集履歴
2
ご指摘された箇所を編集しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -414,6 +414,76 @@
|
|
414
414
|
|
415
415
|
```
|
416
416
|
|
417
|
+
#### 修正後のbreeds_controller.rb
|
418
|
+
|
419
|
+
```ruby
|
420
|
+
|
421
|
+
class InformationsController < ApplicationController
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
def new
|
428
|
+
|
429
|
+
# binding.pry
|
430
|
+
|
431
|
+
@breed = Breed.find(params[:breed_id])
|
432
|
+
|
433
|
+
@information = @breed.build_information
|
434
|
+
|
435
|
+
# @information = Information.new
|
436
|
+
|
437
|
+
end
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
def create
|
442
|
+
|
443
|
+
@information = Information.new(information_params)
|
444
|
+
|
445
|
+
if @information.save
|
446
|
+
|
447
|
+
redirect_to root_path
|
448
|
+
|
449
|
+
else
|
450
|
+
|
451
|
+
render :new
|
452
|
+
|
453
|
+
end
|
454
|
+
|
455
|
+
end
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
def show
|
460
|
+
|
461
|
+
@information = Information.find(params[:breed_id])
|
462
|
+
|
463
|
+
end
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
private
|
468
|
+
|
469
|
+
def information_params
|
470
|
+
|
471
|
+
params.require(:information).permit(:breedname, :locality, :generation_id, :food_id, :memo).merge(breed_id: params[:breed_id])
|
472
|
+
|
473
|
+
end
|
474
|
+
|
475
|
+
end
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
```
|
484
|
+
|
485
|
+
|
486
|
+
|
417
487
|
|
418
488
|
|
419
489
|
### 試したこと
|
1
ご連絡ありがとうございます。 routes.rbを新たに記載しましたのでご確認お願いいたします。
test
CHANGED
File without changes
|
test
CHANGED
@@ -384,6 +384,36 @@
|
|
384
384
|
|
385
385
|
```
|
386
386
|
|
387
|
+
#### routes.rb
|
388
|
+
|
389
|
+
```
|
390
|
+
|
391
|
+
Rails.application.routes.draw do
|
392
|
+
|
393
|
+
root to:"breeds#index"
|
394
|
+
|
395
|
+
devise_for :users
|
396
|
+
|
397
|
+
resources :users, only: :show
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
resources :breeds, only: [:index, :new, :create, :show] do
|
402
|
+
|
403
|
+
resources :informations, only: [:new, :create, :show] do
|
404
|
+
|
405
|
+
resources :more_informations, only: [:new, :create, :show]
|
406
|
+
|
407
|
+
end
|
408
|
+
|
409
|
+
end
|
410
|
+
|
411
|
+
end
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
```
|
416
|
+
|
387
417
|
|
388
418
|
|
389
419
|
### 試したこと
|