简体   繁体   English

表单部分不渲染滑轨

[英]Form partial not rendering rails

I don't get any error messages when I load the page the only issue is the the comments form isn't rendering in the browser. 加载页面时没有收到任何错误消息,唯一的问题是注释表单未在浏览器中呈现。

<div class="col-sm-11 col-xs-12 blog-content">
<h2 class="text-center"><%= @post.title %></h2>
<h5 class="text-center"><%= @post.created_at.strftime('%b %d, %Y') %></h5>
<div><%= raw @post.body %></div>
<br>
<h2><%= @post.comments.count %></h2>
<%= render @post.comments %>
<h3>Add a comment...</h3>
<%= render partial: 'comments/form'%>
</div>

Here is the comments form I am trying to render. 这是我要呈现的评论表格。

<%= form_for([@post, @post.comments.build]) do |f| %>
    <p>
        <%= f.label :body%><br>
        <%= f.text_area :body%>
    </p>
    <br>
    <p>
        <%= f.submit %>
    </p>
<% end %>

The comments partial form should exist in this full path app/views/comments/_form.html.erb . 注释的部分形式应存在于此完整路径app / views / comments / _form.html.erb中 Then this should work 然后这应该工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM