リビジョン cffd7877
| app/controllers/glossary_terms_controller.rb | ||
|---|---|---|
|
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
|
||
| app/views/glossary_terms/show.html.erb | ||
|---|---|---|
|
<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>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
# English strings go here for Rails i18n
|
||
|
en:
|
||
|
label_glossary_terms: "Glossary terms"
|
||
|
|
||
|
label_glossary_term: "Glossary term"
|
||
| config/locales/ja.yml | ||
|---|---|---|
|
ja:
|
||
|
label_glossary_terms: "用語集"
|
||
|
label_glossary_term: "用語"
|
||
|
|
||
| config/routes.rb | ||
|---|---|---|
|
# See: http://guides.rubyonrails.org/routing.html
|
||
|
|
||
|
Rails.application.routes.draw do
|
||
|
resources :glossary_terms, only: [:index]
|
||
|
resources :glossary_terms, only: [:index, :show]
|
||
|
end
|
||
[phase-3]add show action in minimum