我收到错误:
Missing partial post/questions, application/questions with
{:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}.
Searched in:* "/Users/..../<project name>/app/views"
我试图将数据库中的所有帖子呈现给index.html.erb
.
我的视图部分是post/index.html.erb
:
<!--html codes -->
<%= render 'questions' %>
控制器controller/post_controller.rb
:
def index
@posts=Post.all
end
def questions
end
questions.html.erb
<%[email protected] /cdn-cgi/l/email-protection do |post| %>
<table>
<tr>
<td>
<h2>
<%=post.title%>
</h2>
</td>
</tr>
<tr>
<td>
<h3><%=post.body%></h3>
</td>
</tr>
<tr>
<td>
This Post comes under:<h4><%=post.tag%></h4>
</td>
</tr>
</table>
部分文件名必须以下划线开头。您应该将 _questions.html.erb 保存在 post 文件夹中。此外,您不需要定义“问题”操作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)