プロジェクト

全般

プロフィール

« | » 

リビジョン a89d77b4

高徹 高橋 徹 さんが約6年前に追加

[phase-4]add new form

差分を表示:

app/controllers/glossary_terms_controller.rb
@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
app/views/glossary_terms/_form.html.erb
<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>
app/views/glossary_terms/new.html.erb
<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 %>
config/locales/en.yml
en:
label_glossary_terms: "Glossary terms"
label_glossary_term: "Glossary term"
label_glossary_term_new: "New glossary term"
config/locales/ja.yml
ja:
label_glossary_terms: "用語集"
label_glossary_term: "用語"
label_glossary_term_new: "用語の作成"
config/routes.rb
# 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

他の形式にエクスポート: Unified diff