Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – Rails中缺少部分错误3大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我收到一个错误: @H_404_2@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' %>

控制器控制器/ 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>

解决方法

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

大佬总结

以上是大佬教程为你收集整理的ruby-on-rails – Rails中缺少部分错误3全部内容,希望文章能够帮你解决ruby-on-rails – Rails中缺少部分错误3所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。