Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit 3f30003

Browse files
committed
Adapt index views for dependencies and comments
1 parent 211971d commit 3f30003

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

app/views/comments/_form.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
<div class="field">
2525
<%= form.label :dependency_id %>
26-
<%= form.text_field :dependency_id %>
26+
<%= select_tag(:dependency_id,
27+
options_for_select(Dependency.all.map { |d| [d.name, d.id] })) %>
2728
</div>
2829

2930
<div class="actions">

app/views/comments/index.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<tr>
1818
<td><%= comment.body %></td>
1919
<td><%= comment.published %></td>
20-
<td><%= comment.dependency %></td>
20+
<td><%= comment.dependency.name %></td>
2121
<td><%= link_to 'Show', comment %></td>
2222
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
2323
<td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
@@ -29,3 +29,4 @@
2929
<br>
3030

3131
<%= link_to 'New Comment', new_comment_path %>
32+
<%= link_to "Back to dependencies", dependencies_path %>

app/views/comments/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<p>
1414
<strong>Dependency:</strong>
15-
<%= @comment.dependency %>
15+
<%= @comment.dependency.name %>
1616
</p>
1717

1818
<%= link_to 'Edit', edit_comment_path(@comment) %> |

app/views/dependencies/index.html.erb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@
1414
<% @dependencies.each do |dependency| %>
1515
<tr>
1616
<td><%= dependency.name %></td>
17+
<td><%= "#{dependency.comments.count}\
18+
#{Comment.model_name.human(count: dependency.comments.count)}" %></td>
1719
<td><%= link_to 'Show', dependency %></td>
1820
<td><%= link_to 'Edit', edit_dependency_path(dependency) %></td>
19-
<td><%= link_to 'Destroy', dependency, method: :delete, data: { confirm: 'Are you sure?' } %></td>
21+
<td><%= link_to 'Destroy', dependency, method: :delete,
22+
data: { confirm: 'Are you sure?' } %></td>
2023
</tr>
2124
<% end %>
2225
</tbody>
@@ -25,3 +28,4 @@
2528
<br>
2629

2730
<%= link_to 'New Dependency', new_dependency_path %>
31+
<%= link_to "See Comments", comments_path %>

config/locales/en.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
en:
2+
activerecord:
3+
models:
4+
comment:
5+
one: comment
6+
other: comments

0 commit comments

Comments
 (0)