質問編集履歴

2

コード追加

2019/12/17 06:37

投稿

majikadezou
majikadezou

スコア34

test CHANGED
File without changes
test CHANGED
@@ -195,3 +195,69 @@
195
195
  ```
196
196
 
197
197
  となって読み取れていないようです。どなたか原因が分かる方はいらっしゃいませんか?
198
+
199
+
200
+
201
+ ```
202
+
203
+ create時のログ
204
+
205
+
206
+
207
+ Started POST "/microposts" for ::1 at 2019-12-16 21:43:29 +0900
208
+
209
+ Processing by MicropostsController#create as HTML
210
+
211
+ Parameters: {"authenticity_token"=>"V0UoBbmVx9oKmvkJ4C1I2cDb4oxAPI0XIt/1Byuf18/jv/5xUHo09B33/dmsTJFDGGsfMQBoSAchMpXlep4/lw==", "memo"=>"ああああああ", "commit"=>"記録する"}
212
+
213
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
214
+
215
+ ↳ app/helpers/sessions_helper.rb:16:in `current_user'
216
+
217
+ Completed 400 Bad Request in 2ms (ActiveRecord: 0.2ms | Allocations: 1202)
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+ ActionController::ParameterMissing (param is missing or the value is empty: micropost):
226
+
227
+
228
+
229
+ app/controllers/microposts_controller.rb:45:in `micropost_params'
230
+
231
+ app/controllers/microposts_controller.rb:7:in `create'
232
+
233
+ Started GET "/microposts/148/edit" for ::1 at 2019-12-16 21:47:04 +0900
234
+
235
+ Processing by MicropostsController#edit as HTML
236
+
237
+ Parameters: {"id"=>"148"}
238
+
239
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
240
+
241
+ ↳ app/helpers/sessions_helper.rb:16:in `current_user'
242
+
243
+ Micropost Load (0.3ms) SELECT "microposts".* FROM "microposts" WHERE "microposts"."user_id" = ? AND "microposts"."id" = ? ORDER BY "microposts"."created_at" DESC LIMIT ? [["user_id", 1], ["id", 148], ["LIMIT", 1]]
244
+
245
+ ↳ app/controllers/microposts_controller.rb:18:in `edit'
246
+
247
+ Rendering microposts/edit.html.erb within layouts/application
248
+
249
+ Rendered shared/_error_messages.html.erb (Duration: 0.3ms | Allocations: 75)
250
+
251
+ Rendered microposts/edit.html.erb within layouts/application (Duration: 7.6ms | Allocations: 2045)
252
+
253
+ [Webpacker] Everything's up-to-date. Nothing to do
254
+
255
+ Rendered layouts/_header.html.erb (Duration: 3.0ms | Allocations: 1392)
256
+
257
+ Rendered layouts/_footer.html.erb (Duration: 0.7ms | Allocations: 134)
258
+
259
+ Completed 200 OK in 47ms (Views: 40.0ms | ActiveRecord: 0.5ms | Allocations: 14740)
260
+
261
+ コード
262
+
263
+ ```

1

コード追加

2019/12/17 06:37

投稿

majikadezou
majikadezou

スコア34

test CHANGED
File without changes
test CHANGED
@@ -43,6 +43,80 @@
43
43
  </div>
44
44
 
45
45
 
46
+
47
+ ```
48
+
49
+ ```
50
+
51
+ microposts/edit.html.erb
52
+
53
+
54
+
55
+ <% provide(:title, 'メモ編集') %>
56
+
57
+ <div class="container micropost-edit-container">
58
+
59
+ <div class="edit-titles">
60
+
61
+ <%= image_tag 'pencil.png', class: 'edit-img' %>
62
+
63
+ <h1 class="title edit-micropost-title">メモ編集</h1>
64
+
65
+ </div>
66
+
67
+ <%= form_with(model: @micropost, url: micropost_path, local: true) do |form| %>
68
+
69
+ <%= render 'shared/error_messages', object: form.object %>
70
+
71
+ <div class="form-group">
72
+
73
+ <%= form.label :memo, 'メモ' %>
74
+
75
+ <%= form.text_area :memo, class: 'form-control', placeholder: @micropost.memo %>
76
+
77
+ </div>
78
+
79
+ <div class="form-group">
80
+
81
+ <%= form.label :picture, '画像' %>
82
+
83
+ <%= form.file_field :picture, class: 'form-control-file', placeholder: @micropost.picture %>
84
+
85
+ </div>
86
+
87
+ <div class="row">
88
+
89
+ <div class="col">
90
+
91
+ <div class="form-group">
92
+
93
+ <%= link_to "削除", micropost_path, method: :delete, data: { confirm: "本当に削除しますか?" }, class: 'btn btn-lg btn-danger btn-edit-user' %>
94
+
95
+ </div>
96
+
97
+ </div>
98
+
99
+ <div class="col">
100
+
101
+ <div class="form-group">
102
+
103
+ <%= form.submit "編集", class: 'btn btn-info btn-lg btn-edit-user' %>
104
+
105
+ </div>
106
+
107
+ </div>
108
+
109
+ </div>
110
+
111
+ <div class="form-group">
112
+
113
+ <%= link_to "戻る", current_user, class: 'btn btn-lg btn-edit-user btn-back' %>
114
+
115
+ </div>
116
+
117
+ <% end %>
118
+
119
+ </div>
46
120
 
47
121
  ```
48
122