[phase-4]add new form

This commit is contained in:
Toru Takahashi 2018-05-05 11:15:27 +09:00 committed by TAKAHASHI,Toru
parent fe7395a659
commit a89d77b4f6
6 changed files with 17 additions and 5 deletions

View File

@ -6,9 +6,9 @@ class GlossaryTermsController < ApplicationController
@glossary_terms = GlossaryTerm.all @glossary_terms = GlossaryTerm.all
end end
# def show def new
@term = GlossaryTerm.new
# end end
# Find the term whose id is the :id parameter # Find the term whose id is the :id parameter
def find_term_from_id def find_term_from_id

View File

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

View File

@ -0,0 +1,7 @@
<h2><%=l :label_glossary_term_new %></h2>
<%= 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 %>

View File

@ -2,3 +2,4 @@
en: en:
label_glossary_terms: "Glossary terms" label_glossary_terms: "Glossary terms"
label_glossary_term: "Glossary term" label_glossary_term: "Glossary term"
label_glossary_term_new: "New glossary term"

View File

@ -1,4 +1,4 @@
ja: ja:
label_glossary_terms: "用語集" label_glossary_terms: "用語集"
label_glossary_term: "用語" label_glossary_term: "用語"
label_glossary_term_new: "用語の作成"

View File

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