diff --git a/app/controllers/glossary_terms_controller.rb b/app/controllers/glossary_terms_controller.rb index f2f5767..5cb2a10 100644 --- a/app/controllers/glossary_terms_controller.rb +++ b/app/controllers/glossary_terms_controller.rb @@ -6,9 +6,9 @@ class GlossaryTermsController < ApplicationController @glossary_terms = GlossaryTerm.all end -# def show - -# end + def new + @term = GlossaryTerm.new + end # Find the term whose id is the :id parameter def find_term_from_id diff --git a/app/views/glossary_terms/_form.html.erb b/app/views/glossary_terms/_form.html.erb new file mode 100644 index 0000000..e3da80d --- /dev/null +++ b/app/views/glossary_terms/_form.html.erb @@ -0,0 +1,4 @@ +
+

<%= form.text_field :name, size: 80, required: true %>

+

<%= form.text_area :description, size: "80x10", required: false %>

+
diff --git a/app/views/glossary_terms/new.html.erb b/app/views/glossary_terms/new.html.erb new file mode 100644 index 0000000..e7f59c1 --- /dev/null +++ b/app/views/glossary_terms/new.html.erb @@ -0,0 +1,7 @@ +

<%=l :label_glossary_term_new %>

+ +<%= labelled_form_for :glossary_term, @term, + url: glossary_terms_path do |f| %> + <%= render partial: 'glossary_terms/form', locals: {form: f} %> + <%= f.submit l(:button_create) %> +<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 1c53864..c403bbd 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,3 +2,4 @@ en: label_glossary_terms: "Glossary terms" label_glossary_term: "Glossary term" + label_glossary_term_new: "New glossary term" \ No newline at end of file diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 14300a3..e3dcb96 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -1,4 +1,4 @@ ja: label_glossary_terms: "用語集" label_glossary_term: "用語" - \ No newline at end of file + label_glossary_term_new: "用語の作成" \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 396cc9a..d003913 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, :show] + resources :glossary_terms, only: [:index, :show, :new, :create] end