ruby-on-rails – Rails中缺少部分错误3
发布时间:2020-12-16 21:32:21 所属栏目:百科 来源:网络整理
导读:我收到一个错误: 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.
我收到一个错误:
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.此外,您无需定义“问题”操作.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |