質問編集履歴
1
routes.rbとcontrollerの内容を追加しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -7,3 +7,75 @@
|
|
7
7
|
|
8
8
|
|
9
9
|
![イメージ説明](5a39cf71d8685d01d23b5cd349b17454.png)
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
routes.rbとcontrollerはそれぞれ以下のようになっています。
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
Rails.application.routes.draw do
|
18
|
+
|
19
|
+
get 'todolists/new'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
get 'top' => 'root#top'
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
post 'todolists' => 'todolists#create'
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
class TodolistsController < ApplicationController
|
38
|
+
|
39
|
+
def new
|
40
|
+
|
41
|
+
@list = List.new
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
def create
|
48
|
+
|
49
|
+
list = List.new(list_params)
|
50
|
+
|
51
|
+
list.save
|
52
|
+
|
53
|
+
redirect_top '/top'
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
def index
|
60
|
+
|
61
|
+
@lists = List.all
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
def list_params
|
72
|
+
|
73
|
+
params.require(:list).permit(:title, :body)
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
```
|