質問編集履歴
8
createの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -164,8 +164,6 @@
|
|
164
164
|
|
165
165
|
#変更
|
166
166
|
@tasks = TaskCollection.new(current_user, tasks_params)
|
167
|
-
@tasks.collection.each{|task| task.save! }
|
168
|
-
@tasks.each{|task| task.save! }
|
169
167
|
if @tasks.save
|
170
168
|
flash[:success] = "作成しました!"
|
171
169
|
redirect_to task_path(current_user)
|
7
エラー画面の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|

|
12
12
|
New!
|
13
13
|
エラー画面
|
14
|
-

|
15
15
|
app/views/tasks/new.html.erb
|
16
16
|
```
|
17
17
|
<%= form_with model: @tasks, url: tasks_path, local: true do |form| %>
|
6
createの変更とエラー画面の変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|

|
12
12
|
New!
|
13
13
|
エラー画面
|
14
|
-

|
15
15
|
app/views/tasks/new.html.erb
|
16
16
|
```
|
17
17
|
<%= form_with model: @tasks, url: tasks_path, local: true do |form| %>
|
@@ -163,15 +163,13 @@
|
|
163
163
|
end
|
164
164
|
|
165
165
|
#変更
|
166
|
+
@tasks = TaskCollection.new(current_user, tasks_params)
|
166
|
-
|
167
|
+
@tasks.collection.each{|task| task.save! }
|
167
168
|
@tasks.each{|task| task.save! }
|
168
169
|
if @tasks.save
|
169
170
|
flash[:success] = "作成しました!"
|
170
171
|
redirect_to task_path(current_user)
|
171
172
|
else
|
172
|
-
render 'new'
|
173
|
-
end
|
174
|
-
end
|
175
173
|
|
176
174
|
def update
|
177
175
|
if current_user.update(user_tasks_params)
|
5
createの変更とエラー画面の変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|

|
12
12
|
New!
|
13
13
|
エラー画面
|
14
|
-

|
15
15
|
app/views/tasks/new.html.erb
|
16
16
|
```
|
17
17
|
<%= form_with model: @tasks, url: tasks_path, local: true do |form| %>
|
@@ -163,9 +163,9 @@
|
|
163
163
|
end
|
164
164
|
|
165
165
|
#変更
|
166
|
-
def create
|
167
|
-
|
166
|
+
@tasks.collection.each{|task| task.save! }
|
168
|
-
|
167
|
+
@tasks.each{|task| task.save! }
|
168
|
+
if @tasks.save
|
169
169
|
flash[:success] = "作成しました!"
|
170
170
|
redirect_to task_path(current_user)
|
171
171
|
else
|
4
createを指摘されたように変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -162,9 +162,10 @@
|
|
162
162
|
@tasks = TaskCollection.new(current_user)
|
163
163
|
end
|
164
164
|
|
165
|
+
#変更
|
165
166
|
def create
|
166
167
|
@tasks = TaskCollection.new(current_user, tasks_params)
|
167
|
-
if @tasks.save
|
168
|
+
if @tasks.each{|task| task.save! }
|
168
169
|
flash[:success] = "作成しました!"
|
169
170
|
redirect_to task_path(current_user)
|
170
171
|
else
|
3
エラー画面の追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -9,8 +9,9 @@
|
|
9
9
|
**問題が発生するまでの流れ・手順**
|
10
10
|
new.html.erbでフォームに入力して登録ボタンを押した時
|
11
11
|

|
12
|
-
|
12
|
+
New!
|
13
|
-
|
13
|
+
エラー画面
|
14
|
+

|
14
15
|
app/views/tasks/new.html.erb
|
15
16
|
```
|
16
17
|
<%= form_with model: @tasks, url: tasks_path, local: true do |form| %>
|
2
エラーログの変更とタイポの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
<%= @tasks.errors.messages[:priority][0] %>
|
33
33
|
</div>
|
34
34
|
<% end %>
|
35
|
-
<p><%= field.label :content", class: 'label' %></p><br>
|
35
|
+
<p><%= field.label :"content", class: 'label' %></p><br>
|
36
36
|
<p><%= field.text_area :content, class: 'tasks-form-area' %></p><br>
|
37
37
|
<% if @tasks.errors.include?(:content) %>
|
38
38
|
<div class="alert alert-danger">
|
@@ -254,34 +254,28 @@
|
|
254
254
|
```
|
255
255
|
**ログ
|
256
256
|
|
257
|
-
Started POST "/tasks" for 172.18.0.1 at 2021-03-12
|
258
|
-
Processing by TasksController#create as HTML
|
259
|
-
Parameters: {"utf8"=>"✓", "authenticity_token"=>
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
Rendered layouts/_shim.html.erb (0.5ms)
|
280
|
-
Rendered layouts/_head.html.erb (444.9ms)
|
281
|
-
Rendered layouts/_header.html.erb (1.8ms)
|
282
|
-
Rendered layouts/_flash_messages.html.erb (0.7ms)
|
283
|
-
Rendered layouts/_footer.html.erb (3.8ms)
|
284
|
-
Completed 200 OK in 765ms (Views: 632.8ms | ActiveRecord: 7.2ms)
|
257
|
+
Started POST "/tasks" for 172.18.0.1 at 2021-03-12 08:00:41 +0000
|
258
|
+
web_1 | Processing by TasksController#create as HTML
|
259
|
+
web_1 | Parameters: {"utf8"=>"✓", "authenticity_token"=>"YGJn1DCr5ZPyJoB9kLvySBof7vj2II4iLb6KQFj+OtXqy0C1bMZ162jmby9s+XZrTcLaHNIz2B4RK39fS7U9Lg==", "tasks"=>[{"title"=>"task0", "priority"=>"0", "content"=>""}, {"title"=>"task1", "priority"=>"1", "content"=>""}, {"title"=>"task2", "priority"=>"2", "content"=>""}], "commit"=>"一括登録"}
|
260
|
+
web_1 | User Load (0.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1
|
261
|
+
web_1 | (0.6ms) BEGIN
|
262
|
+
web_1 | User Load (1.6ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1
|
263
|
+
web_1 | Task Exists (0.8ms) SELECT 1 AS one FROM `tasks` WHERE `tasks`.`priority` = 0 LIMIT 1
|
264
|
+
web_1 | CACHE User Load (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1
|
265
|
+
web_1 | Task Exists (0.8ms) SELECT 1 AS one FROM `tasks` WHERE `tasks`.`priority` = 1 LIMIT 1
|
266
|
+
web_1 | CACHE User Load (0.0ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1
|
267
|
+
web_1 | Task Exists (3.7ms) SELECT 1 AS one FROM `tasks` WHERE `tasks`.`priority` = 2 LIMIT 1
|
268
|
+
web_1 | (0.7ms) ROLLBACK
|
269
|
+
web_1 | "エラー"
|
270
|
+
web_1 | Rendering tasks/new.html.erb within layouts/application
|
271
|
+
web_1 | Rendered tasks/new.html.erb within layouts/application (14.4ms)
|
272
|
+
web_1 | Rendered layouts/_shim.html.erb (1.1ms)
|
273
|
+
web_1 | Rendered layouts/_head.html.erb (1440.8ms)
|
274
|
+
web_1 | Rendered layouts/_header.html.erb (3.3ms)
|
275
|
+
web_1 | Rendered layouts/_flash_messages.html.erb (1.3ms)
|
276
|
+
web_1 | Rendered layouts/_footer.html.erb (7.9ms)
|
277
|
+
web_1 | Completed 200 OK in 2111ms (Views: 1884.7ms | ActiveRecord: 13.0ms)
|
278
|
+
|
285
279
|
|
286
280
|
|
287
281
|
|
1
インデントの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -184,7 +184,8 @@
|
|
184
184
|
|
185
185
|
# ストロングパラメーターcreate用
|
186
186
|
def tasks_params
|
187
|
-
params.require(:tasks)
|
187
|
+
params.require(:tasks)
|
188
|
+
end
|
188
189
|
|
189
190
|
|
190
191
|
# ストロングパラメーターupdate用
|
@@ -260,7 +261,8 @@
|
|
260
261
|
d2Ahv7GtklZfOKQNvXIT1ecRowUDQ==",
|
261
262
|
"tasks"=>[{"title"=>"task0",
|
262
263
|
"priority"=>"0", "content"=>""},
|
264
|
+
{"title"=>"task1", "priority"=>"1", "content"=>""},
|
263
|
-
|
265
|
+
{"title"=>"task2", "priority"=>"2", "content"=>""}],
|
264
266
|
"commit"=>"一括登録"}
|
265
267
|
User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 4 LIMIT 1
|
266
268
|
(0.3ms) BEGIN
|