質問編集履歴
2
index.html.erbの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -81,3 +81,69 @@
|
|
81
81
|
<% end %>
|
82
82
|
|
83
83
|
```
|
84
|
+
|
85
|
+
index.html.erb
|
86
|
+
|
87
|
+
```
|
88
|
+
|
89
|
+
<p id="notice"><%#= notice %></p>
|
90
|
+
|
91
|
+
<% x=0 %>
|
92
|
+
|
93
|
+
<%#ホームで入力%>
|
94
|
+
|
95
|
+
新しいToDoを作成する
|
96
|
+
|
97
|
+
<%= render 'form', todo: @todo %>
|
98
|
+
|
99
|
+
<table>
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<tbody>
|
104
|
+
|
105
|
+
<% @todos.each.with_index(1) do |todo,i| %>
|
106
|
+
|
107
|
+
<tr>
|
108
|
+
|
109
|
+
<td><%= todo.content %></td>
|
110
|
+
|
111
|
+
<td>期限:<%=todo.limit %></td>
|
112
|
+
|
113
|
+
<td>作成日:<%=todo.created_at.strftime('%Y/%m/%d') %></td><%#作成日時%>
|
114
|
+
|
115
|
+
<% if todo.status=="undone" %>
|
116
|
+
|
117
|
+
<td><%= button_to "未完了", done_path(todo), method: :post %></td><%#完了ボタン%>
|
118
|
+
|
119
|
+
<% else %>
|
120
|
+
|
121
|
+
<td><%= button_to "完了", done_path(todo), method: :post %></td><%#完了ボタン%>
|
122
|
+
|
123
|
+
<% end %>
|
124
|
+
|
125
|
+
<td><%#= link_to 'Show', todo %></td>
|
126
|
+
|
127
|
+
<td><%= link_to '編集', edit_todo_path(todo) %></td>
|
128
|
+
|
129
|
+
<td><%= link_to 'Destroy', todo, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
130
|
+
|
131
|
+
</tr>
|
132
|
+
|
133
|
+
<% x=i %>
|
134
|
+
|
135
|
+
<% end %>
|
136
|
+
|
137
|
+
</tbody>
|
138
|
+
|
139
|
+
</table>
|
140
|
+
|
141
|
+
<% if x==0 %>
|
142
|
+
|
143
|
+
登録されたToDoはございません
|
144
|
+
|
145
|
+
<% end %>
|
146
|
+
|
147
|
+
<br>
|
148
|
+
|
149
|
+
```
|
1
ソースコード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,4 +18,66 @@
|
|
18
18
|
|
19
19
|
### 該当のソースコード
|
20
20
|
|
21
|
+
_form.html.erb
|
22
|
+
|
23
|
+
```
|
24
|
+
|
25
|
+
<%= form_with(model: todo, local: true) do |form| %>
|
26
|
+
|
27
|
+
<% if todo.errors.any? %>
|
28
|
+
|
29
|
+
<div id="error_explanation">
|
30
|
+
|
31
|
+
<h2><%= pluralize(todo.errors.count, "error") %> prohibited this todo from being saved:</h2>
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<% todo.errors.full_messages.each do |message| %>
|
38
|
+
|
39
|
+
<li><%= message %></li>
|
40
|
+
|
41
|
+
<% end %>
|
42
|
+
|
43
|
+
</ul>
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<% end %>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
<div class="field">
|
56
|
+
|
57
|
+
<%= form.label "ToDo名" %>
|
58
|
+
|
59
|
+
<%= form.text_area :content, id: :todo_content %>
|
60
|
+
|
61
|
+
</div>
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<div class="field">
|
66
|
+
|
67
|
+
<%= form.label "期限" %>
|
68
|
+
|
69
|
+
<%= form.date_select :limit, id: :todo_limit %>
|
70
|
+
|
71
|
+
</div>
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
<div class="actions">
|
76
|
+
|
21
|
-
|
77
|
+
<%= form.submit %>
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<% end %>
|
82
|
+
|
83
|
+
```
|