[phase-3]add show action in minimum

This commit is contained in:
Toru Takahashi 2018-05-04 09:40:20 +09:00 committed by TAKAHASHI,Toru
parent 1c17a44d1a
commit cffd7877da
5 changed files with 24 additions and 2 deletions

View File

@ -1,6 +1,17 @@
class GlossaryTermsController < ApplicationController
before_action :find_term_from_id, only: [:show]
def index
@glossary_terms = GlossaryTerm.all
end
# def show
# end
# Find the term whose id is the :id parameter
def find_term_from_id
@term = GlossaryTerm.find(params[:id])
end
end

View File

@ -0,0 +1,10 @@
<h2><%=t :label_glossary_term %> #<%= @term.id %></h2>
<h3><%= @term.name %></h3>
<table>
<tr>
<th><%=t :field_description %></th>
<td><%= @term.description %></td>
</tr>
</table>

View File

@ -1,4 +1,4 @@
# English strings go here for Rails i18n
en:
label_glossary_terms: "Glossary terms"
label_glossary_term: "Glossary term"

View File

@ -1,3 +1,4 @@
ja:
label_glossary_terms: "用語集"
label_glossary_term: "用語"

View File

@ -2,5 +2,5 @@
# See: http://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
resources :glossary_terms, only: [:index]
resources :glossary_terms, only: [:index, :show]
end