[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 def glossary_term_params
params.require(:glossary_term).permit( params.require(:glossary_term).permit(
:name, :description :name, :description, :category_id
) )
end end
end end

View File

@ -1,4 +1,5 @@
<div class="box tabular"> <div class="box tabular">
<p><%= form.text_field :name, size: 80, required: true %></p> <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> <p><%= form.text_area :description, size: "80x10", required: false %></p>
</div> </div>

View File

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

View File

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