以下是错误消息:
ActionView::MissingTemplate in Posts#new Showing /Users/Tish/code/bloccit/app/views/posts/new.html.erb where line #18 raised:
Missing partial posts/_form, application/_form with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in: * "/Users/Tish/code/bloccit/app/views" * "/usr/local/rvm/gems/ruby-2.0.0-p353/gems/devise-3.4.1/app/views" Extracted source (around line #18): 15 16 17 18 19 20 21
<div class="col-md-8">
<%= render partial: 'form', locals: { topic: @topic, post: @post } %>
</div>
</div>
Rails.root: /Users/Tish/code/bloccit
Application Trace | Framework Trace | Full Trace app/views/posts/new.html.erb:18:in `_app_views_posts_new_html_erb__1906244960834792437_2160461360'
答案 0 :(得分:1)
在app/views/posts/new.html.erb
<%= render :partial => 'form' %>
在app/views/posts/_form.html.erb
<%= form_for [@topic, @post] do |f| %>
<div class="form-group">
<%= f.label :title %>
<%= f.text_field :title, class: 'form-control', placeholder: "Enter post title" %>
</div>
<div class="form-group">
<%= f.label :body %>
<%= f.text_area :body, rows: 8, class: 'form-control', placeholder: "Enter post body" %>
</div>
<div class="form-group">
<%= f.submit "Save", class: 'btn btn-success' %>
</div>
<% end %>