6

我收到一个错误:

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

    <%=@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>
4

1 回答 1

17

分部的文件名必须以下划线开头。您应该将 _questions.html.erb 保存在 post 文件夹中。此外,您不需要定义“问题”操作。

于 2012-06-08T06:04:11.940 回答