teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

コード追加

2019/12/17 06:37

投稿

majikadezou
majikadezou

スコア34

title CHANGED
File without changes
body CHANGED
@@ -96,4 +96,37 @@
96
96
  app/controllers/microposts_controller.rb:44:in `micropost_params'
97
97
  app/controllers/microposts_controller.rb:7:in `create'
98
98
  ```
99
- となって読み取れていないようです。どなたか原因が分かる方はいらっしゃいませんか?
99
+ となって読み取れていないようです。どなたか原因が分かる方はいらっしゃいませんか?
100
+
101
+ ```
102
+ create時のログ
103
+
104
+ Started POST "/microposts" for ::1 at 2019-12-16 21:43:29 +0900
105
+ Processing by MicropostsController#create as HTML
106
+ Parameters: {"authenticity_token"=>"V0UoBbmVx9oKmvkJ4C1I2cDb4oxAPI0XIt/1Byuf18/jv/5xUHo09B33/dmsTJFDGGsfMQBoSAchMpXlep4/lw==", "memo"=>"ああああああ", "commit"=>"記録する"}
107
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
108
+ ↳ app/helpers/sessions_helper.rb:16:in `current_user'
109
+ Completed 400 Bad Request in 2ms (ActiveRecord: 0.2ms | Allocations: 1202)
110
+
111
+
112
+
113
+ ActionController::ParameterMissing (param is missing or the value is empty: micropost):
114
+
115
+ app/controllers/microposts_controller.rb:45:in `micropost_params'
116
+ app/controllers/microposts_controller.rb:7:in `create'
117
+ Started GET "/microposts/148/edit" for ::1 at 2019-12-16 21:47:04 +0900
118
+ Processing by MicropostsController#edit as HTML
119
+ Parameters: {"id"=>"148"}
120
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 1], ["LIMIT", 1]]
121
+ ↳ app/helpers/sessions_helper.rb:16:in `current_user'
122
+ 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]]
123
+ ↳ app/controllers/microposts_controller.rb:18:in `edit'
124
+ Rendering microposts/edit.html.erb within layouts/application
125
+ Rendered shared/_error_messages.html.erb (Duration: 0.3ms | Allocations: 75)
126
+ Rendered microposts/edit.html.erb within layouts/application (Duration: 7.6ms | Allocations: 2045)
127
+ [Webpacker] Everything's up-to-date. Nothing to do
128
+ Rendered layouts/_header.html.erb (Duration: 3.0ms | Allocations: 1392)
129
+ Rendered layouts/_footer.html.erb (Duration: 0.7ms | Allocations: 134)
130
+ Completed 200 OK in 47ms (Views: 40.0ms | ActiveRecord: 0.5ms | Allocations: 14740)
131
+ コード
132
+ ```

1

コード追加

2019/12/17 06:37

投稿

majikadezou
majikadezou

スコア34

title CHANGED
File without changes
body CHANGED
@@ -22,8 +22,45 @@
22
22
  </div>
23
23
 
24
24
  ```
25
+ ```
26
+ microposts/edit.html.erb
25
27
 
28
+ <% provide(:title, 'メモ編集') %>
29
+ <div class="container micropost-edit-container">
30
+ <div class="edit-titles">
31
+ <%= image_tag 'pencil.png', class: 'edit-img' %>
32
+ <h1 class="title edit-micropost-title">メモ編集</h1>
33
+ </div>
34
+ <%= form_with(model: @micropost, url: micropost_path, local: true) do |form| %>
35
+ <%= render 'shared/error_messages', object: form.object %>
36
+ <div class="form-group">
37
+ <%= form.label :memo, 'メモ' %>
38
+ <%= form.text_area :memo, class: 'form-control', placeholder: @micropost.memo %>
39
+ </div>
40
+ <div class="form-group">
41
+ <%= form.label :picture, '画像' %>
42
+ <%= form.file_field :picture, class: 'form-control-file', placeholder: @micropost.picture %>
43
+ </div>
44
+ <div class="row">
45
+ <div class="col">
46
+ <div class="form-group">
47
+ <%= link_to "削除", micropost_path, method: :delete, data: { confirm: "本当に削除しますか?" }, class: 'btn btn-lg btn-danger btn-edit-user' %>
48
+ </div>
49
+ </div>
50
+ <div class="col">
51
+ <div class="form-group">
52
+ <%= form.submit "編集", class: 'btn btn-info btn-lg btn-edit-user' %>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ <div class="form-group">
57
+ <%= link_to "戻る", current_user, class: 'btn btn-lg btn-edit-user btn-back' %>
58
+ </div>
59
+ <% end %>
60
+ </div>
26
61
  ```
62
+
63
+ ```
27
64
  microposts_controller.rb
28
65
 
29
66
  class MicropostsController < ApplicationController