質問編集履歴
2
index.html.erbの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -39,4 +39,37 @@
|
|
39
39
|
<%= form.submit %>
|
40
40
|
</div>
|
41
41
|
<% end %>
|
42
|
+
```
|
43
|
+
index.html.erb
|
44
|
+
```
|
45
|
+
<p id="notice"><%#= notice %></p>
|
46
|
+
<% x=0 %>
|
47
|
+
<%#ホームで入力%>
|
48
|
+
新しいToDoを作成する
|
49
|
+
<%= render 'form', todo: @todo %>
|
50
|
+
<table>
|
51
|
+
|
52
|
+
<tbody>
|
53
|
+
<% @todos.each.with_index(1) do |todo,i| %>
|
54
|
+
<tr>
|
55
|
+
<td><%= todo.content %></td>
|
56
|
+
<td>期限:<%=todo.limit %></td>
|
57
|
+
<td>作成日:<%=todo.created_at.strftime('%Y/%m/%d') %></td><%#作成日時%>
|
58
|
+
<% if todo.status=="undone" %>
|
59
|
+
<td><%= button_to "未完了", done_path(todo), method: :post %></td><%#完了ボタン%>
|
60
|
+
<% else %>
|
61
|
+
<td><%= button_to "完了", done_path(todo), method: :post %></td><%#完了ボタン%>
|
62
|
+
<% end %>
|
63
|
+
<td><%#= link_to 'Show', todo %></td>
|
64
|
+
<td><%= link_to '編集', edit_todo_path(todo) %></td>
|
65
|
+
<td><%= link_to 'Destroy', todo, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
66
|
+
</tr>
|
67
|
+
<% x=i %>
|
68
|
+
<% end %>
|
69
|
+
</tbody>
|
70
|
+
</table>
|
71
|
+
<% if x==0 %>
|
72
|
+
登録されたToDoはございません
|
73
|
+
<% end %>
|
74
|
+
<br>
|
42
75
|
```
|
1
ソースコード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,4 +8,35 @@
|
|
8
8
|
scaffoldで作成して、デフォルトでは「Create Todo」と表示されていて変更仕方がわかりません。
|
9
9
|
|
10
10
|
### 該当のソースコード
|
11
|
+
_form.html.erb
|
12
|
+
```
|
13
|
+
<%= form_with(model: todo, local: true) do |form| %>
|
14
|
+
<% if todo.errors.any? %>
|
15
|
+
<div id="error_explanation">
|
16
|
+
<h2><%= pluralize(todo.errors.count, "error") %> prohibited this todo from being saved:</h2>
|
17
|
+
|
18
|
+
<ul>
|
19
|
+
<% todo.errors.full_messages.each do |message| %>
|
20
|
+
<li><%= message %></li>
|
21
|
+
<% end %>
|
22
|
+
</ul>
|
23
|
+
</div>
|
24
|
+
<% end %>
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
<div class="field">
|
29
|
+
<%= form.label "ToDo名" %>
|
30
|
+
<%= form.text_area :content, id: :todo_content %>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="field">
|
34
|
+
<%= form.label "期限" %>
|
35
|
+
<%= form.date_select :limit, id: :todo_limit %>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div class="actions">
|
11
|
-
|
39
|
+
<%= form.submit %>
|
40
|
+
</div>
|
41
|
+
<% end %>
|
42
|
+
```
|