Skip to content

Commit ff4ebf7

Browse files
added delete button to front page since I only had it on my show pages
1 parent e2264ec commit ff4ebf7

7 files changed

Lines changed: 1006 additions & 13 deletions

File tree

app/assets/stylesheets/application.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,14 @@ li a + a {
9090
color: #000;
9191
}
9292

93-
li a + a:hover {
93+
li a:nth-child(2):hover {
9494
color: #808080;
9595
}
9696

97+
li a:last-child:hover {
98+
color: red;
99+
}
100+
97101
/*** forms ***/
98102
form.new_task, form.edit_task {
99103
width: 95%;

app/controllers/tasks_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def new
1313

1414
def create
1515
task = Task.create task_params
16+
task.deadline ||= Time.now
17+
task.save
1618
redirect_to tasks_path unless task.id == nil
1719
end
1820

app/views/tasks/index.html.erb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<main>
22
<h2>Tasks</h2>
3-
43
<ul>
54
<% @tasks.each do |task| %>
65
<li>
@@ -9,12 +8,15 @@
98
<% else %>
109
<%= link_to raw("&#9744;"), toggle_complete_path(task.id), method: :patch %>
1110
<% end %>
11+
1212
<%= link_to task.name, task_path(task.id) %>
13+
<%=
14+
link_to "[delete]", delete_task_path(task.id),
15+
data: { confirm: "Are you sure you want to delete this task?" },
16+
method: :delete
17+
%>
1318
</li>
1419
<% end %>
1520
</ul>
16-
17-
<p>
18-
<%= link_to "Add New Task", new_task_path %>
19-
</p>
21+
<p><%= link_to "Add New Task", new_task_path %></p>
2022
</main>

app/views/tasks/new.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
<h2>Add New Task</h2>
55

66
<%= render partial: "form", locals: { action_name: "Add"} %>
7-
8-
<p><%= link_to "Back to tasks", tasks_path %></p>
7+
8+
<p><%= link_to "Back to Tasks", tasks_path %></p>
99
</main>

app/views/tasks/show.html.erb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,28 @@
33
<main>
44
<h2>
55
<%= @task.name %>
6+
67
<% if @task.completed %>
78
<%= link_to raw("&#9745;"), toggle_complete_path, method: :patch %>
89
<% else %>
910
<%= link_to raw("&#9744;"), toggle_complete_path, method: :patch %>
1011
<% end %>
1112
</h2>
12-
1313
<p><%= @task.description %></p>
14-
1514
<p>
1615
<% if @task.completed %>
1716
<p><%= @task.completed.strftime("Completed on: %m/%d/%Y") %> &check;</p>
1817
<% else %>
1918
<p><%= @task.deadline.strftime("Deadline: %m/%d/%Y") %></p>
2019
<% end %>
2120
</p>
22-
2321
<p>
24-
<%= link_to "Edit Task", edit_task_path %>
22+
<%= link_to "[edit task]", edit_task_path %>
2523
<%=
26-
link_to "Delete Task", delete_task_path,
24+
link_to "[delete task]", delete_task_path,
2725
data: { confirm: "Are you sure you want to delete this task?" },
2826
method: :delete
2927
%>
28+
<%= link_to "Back to Tasks", tasks_path %>
3029
</p>
3130
</main>

db/development.sqlite3

0 Bytes
Binary file not shown.

log/development.log

Lines changed: 986 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)