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

Commit

Permalink
Adapt index views for dependencies and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Polo2 committed Sep 28, 2018
1 parent 211971d commit 3f30003
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/views/comments/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

<div class="field">
<%= form.label :dependency_id %>
<%= form.text_field :dependency_id %>
<%= select_tag(:dependency_id,
options_for_select(Dependency.all.map { |d| [d.name, d.id] })) %>
</div>

<div class="actions">
Expand Down
3 changes: 2 additions & 1 deletion app/views/comments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<tr>
<td><%= comment.body %></td>
<td><%= comment.published %></td>
<td><%= comment.dependency %></td>
<td><%= comment.dependency.name %></td>
<td><%= link_to 'Show', comment %></td>
<td><%= link_to 'Edit', edit_comment_path(comment) %></td>
<td><%= link_to 'Destroy', comment, method: :delete, data: { confirm: 'Are you sure?' } %></td>
Expand All @@ -29,3 +29,4 @@
<br>

<%= link_to 'New Comment', new_comment_path %>
<%= link_to "Back to dependencies", dependencies_path %>
2 changes: 1 addition & 1 deletion app/views/comments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<p>
<strong>Dependency:</strong>
<%= @comment.dependency %>
<%= @comment.dependency.name %>
</p>

<%= link_to 'Edit', edit_comment_path(@comment) %> |
Expand Down
6 changes: 5 additions & 1 deletion app/views/dependencies/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
<% @dependencies.each do |dependency| %>
<tr>
<td><%= dependency.name %></td>
<td><%= "#{dependency.comments.count}\
#{Comment.model_name.human(count: dependency.comments.count)}" %></td>
<td><%= link_to 'Show', dependency %></td>
<td><%= link_to 'Edit', edit_dependency_path(dependency) %></td>
<td><%= link_to 'Destroy', dependency, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<td><%= link_to 'Destroy', dependency, method: :delete,
data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>
Expand All @@ -25,3 +28,4 @@
<br>

<%= link_to 'New Dependency', new_dependency_path %>
<%= link_to "See Comments", comments_path %>
5 changes: 5 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
en:
activerecord:
models:
comment:
one: comment
other: comments

0 comments on commit 3f30003

Please sign in to comment.