gpt4 book ai didi

ruby-on-rails - Rails 3中缺少部分错误

转载 作者:行者123 更新时间:2023-12-03 16:12:33 24 4
gpt4 key购买 nike

我收到一个错误:

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 controller/post_controller.rb:
    def index
@posts=Post.all
end

def questions
end
questions.html.erb
    <%=@posts.each 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文件夹中。另外,您无需定义“问题”操作。

关于ruby-on-rails - Rails 3中缺少部分错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10943744/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com