[phase-5]add category field to term index/detail view, and edit form

This commit is contained in:
Toru Takahashi 2018-05-06 23:39:57 +09:00 committed by TAKAHASHI,Toru
parent b36e22c972
commit 1378a95aa4
4 changed files with 22 additions and 9 deletions

View File

@ -47,7 +47,7 @@ class GlossaryTermsController < ApplicationController
def glossary_term_params
params.require(:glossary_term).permit(
:name, :description
:name, :description, :category_id
)
end
end

View File

@ -1,4 +1,5 @@
<div class="box tabular">
<p><%= form.text_field :name, size: 80, required: true %></p>
<p><%= form.collection_select :category_id, GlossaryCategory.all, :id, :name, include_blank: true %>
<p><%= form.text_area :description, size: "80x10", required: false %></p>
</div>

View File

@ -7,20 +7,28 @@
<table class="list">
<thead>
<tr>
<th>#</th>
<th><%=l :field_name %></th>
<th><%=l :field_category %></th>
<th><%=l :field_description %></th>
</tr>
</thead>
<tbody>
<% @glossary_terms.each do |term| %>
<tr>
<td class="name">
<%= link_to term.name, term %>
</td>
<td class="description">
<%= term.description %>
</td>
</tr>
<tr>
<td class="id">
<%= term.id %>
</td>
<td class="name">
<%= link_to term.name, term %>
</td>
<td class="roles">
<%= term.category.try!(:name) %>
</td>
<td class="description">
<%= term.description %>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@ -9,6 +9,10 @@
<h3><%= @term.name %></h3>
<table>
<tr>
<th><%=l :field_category %></th>
<td><%= @term.category.try!(:name) %>
</tr>
<tr>
<th><%=l :field_description %></th>
<td><%= @term.description %></td>