Rails中缺少部分错误3

时间:2012-06-08 05:58:24

标签: ruby-on-rails

我收到错误:

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>

1 个答案:

答案 0 :(得分:17)

局部模板&#39;文件名必须以下划线开头。您应该在post文件夹中保存_questions.html.erb。此外,您不需要定义问题&#39;动作。