質問編集履歴

2

routes.rbを追記しました。

2019/07/11 04:03

投稿

kpg
kpg

スコア23

test CHANGED
File without changes
test CHANGED
@@ -120,6 +120,34 @@
120
120
 
121
121
 
122
122
 
123
+ routes.rbは下記の内容です。
124
+
125
+ ```rails
126
+
127
+ //routes.rb
128
+
129
+ Rails.application.routes.draw do
130
+
131
+ devise_for :users
132
+
133
+ root 'pictures#index'
134
+
135
+ resources :pictures do
136
+
137
+ resources :comments, only: [:create]
138
+
139
+ end
140
+
141
+ resources :users, only: [:show]
142
+
143
+ end
144
+
145
+
146
+
147
+ ```
148
+
149
+
150
+
123
151
  どなたかご教示頂けますと幸いです。
124
152
 
125
153
 

1

自分での解決方法を追記。

2019/07/11 04:03

投稿

kpg
kpg

スコア23

test CHANGED
File without changes
test CHANGED
@@ -58,7 +58,7 @@
58
58
 
59
59
 
60
60
 
61
- //pictures/controllerのshow.html.haml
61
+ //pictures_controllerのshow.html.haml
62
62
 
63
63
  .details-content__comment
64
64
 
@@ -82,6 +82,44 @@
82
82
 
83
83
 
84
84
 
85
+ 上記のコードでコメントを投稿すると、下記のエラー文が出ます。
86
+
87
+
88
+
89
+ Routing Error
90
+
91
+ No route matches [POST] "/pictures/6"
92
+
93
+
94
+
95
+ pictures_controllerを下記のように修正しましたが、
96
+
97
+ 変わりませんでした。
98
+
99
+
100
+
101
+ ```rails
102
+
103
+ //pictures_controller
104
+
105
+ def show
106
+
107
+ @picture = Picture.find(params[:id])
108
+
109
+ @comment = @comment
110
+
111
+ @comments = @picture.comments.includes(:user)
112
+
113
+ end
114
+
115
+
116
+
117
+
118
+
119
+ ```
120
+
121
+
122
+
85
123
  どなたかご教示頂けますと幸いです。
86
124
 
87
125