From cffd7877da7ba66663d9b6e6f9f9a0bba1938ddd Mon Sep 17 00:00:00 2001 From: Toru Takahashi Date: Fri, 4 May 2018 09:40:20 +0900 Subject: [PATCH] [phase-3]add show action in minimum --- app/controllers/glossary_terms_controller.rb | 11 +++++++++++ app/views/glossary_terms/show.html.erb | 10 ++++++++++ config/locales/en.yml | 2 +- config/locales/ja.yml | 1 + config/routes.rb | 2 +- 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 app/views/glossary_terms/show.html.erb diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb index 88681b3..ebc23a9 100644 --- a/app/controllers/glossary_terms_controller.rb +++ b/app/controllers/glossary_terms_controller.rb @@ -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 diff --git a/app/views/glossary_terms/show.html.erb b/app/views/glossary_terms/show.html.erb new file mode 100644 index 0000000..df2dd24 --- /dev/null +++ b/app/views/glossary_terms/show.html.erb @@ -0,0 +1,10 @@ +

<%=t :label_glossary_term %> #<%= @term.id %>

+ +

<%= @term.name %>

+ + + + + + +
<%=t :field_description %><%= @term.description %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 3864781..1c53864 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,4 +1,4 @@ # English strings go here for Rails i18n en: label_glossary_terms: "Glossary terms" - + label_glossary_term: "Glossary term" diff --git a/config/locales/ja.yml b/config/locales/ja.yml index c51ea70..14300a3 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1,3 +1,4 @@ ja: label_glossary_terms: "用語集" + label_glossary_term: "用語" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index c08e16f..396cc9a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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