Ruby on rails Rails错误缺少模板(haml)
我试图让这个工作,但它显示了一个错误,当我试图加载页面,我试图显示下面的帖子评论Ruby on rails Rails错误缺少模板(haml),ruby-on-rails,haml,erb,Ruby On Rails,Haml,Erb,我试图让这个工作,但它显示了一个错误,当我试图加载页面,我试图显示下面的帖子评论 = render post.comments, post: post 上面这一行是导致问题和错误的那一行,因为找不到模板,它被称为_comment.html.haml .posts-wrapper .post .post-head .thumb-img .user-name = post.user.user_name .image.center-block = l
= render post.comments, post: post
上面这一行是导致问题和错误的那一行,因为找不到模板,它被称为_comment.html.haml
.posts-wrapper
.post
.post-head
.thumb-img
.user-name
= post.user.user_name
.image.center-block
= link_to (image_tag post.image.url(:medium), class:'img-responsive'), post_path(post)
.post-bottom
.caption
.caption-content
.user-name
= post.user.user_name
= post.caption
.comments{id: "comments_#{post.id}"}
- if post.comments
= render post.comments, post: post
.comment-like-form.row
.like-button.col-sm-1
%span(class="glyphicon glyphicon-heart-empty")
.comment-form.col-sm-11
= form_for [post, post.comments.build] do |f|
= f.text_field :content, placeholder: 'Add a comment...', class: "comment_content", id: "comment_content_#{post.id}"
comment是post内部的嵌套路由
下面是应该呈现的部分文件注释
.user-name
= comment.user.user_name
.comment-content
= comment.content
- if comment.user == current_user
= link_to post_comment_path(post, comment), method: :delete, data: { confirm: "Are you sure?" }, remote: true do
%span(class="glyphicon glyphicon-remove delete-comment")
路线:
Rails.application.routes.draw do
devise_for :users, :controllers => { registrations: 'registrations' }
resources :posts do
resources :comments
end
root 'posts#index'
end
谢谢,在我看来,Rails找不到你的部分评论。我猜你把它放在了不该放的地方 您的视图结构应该如下所示:
views
comments
_comment.html.haml
posts
_post.html.haml
_comment.html.haml必须在comments文件夹中。在我看来,Rails找不到您的部分评论。我猜你把它放在了不该放的地方 您的视图结构应该如下所示:
views
comments
_comment.html.haml
posts
_post.html.haml
_comment.html.haml必须在comments文件夹中。请添加路由文件。错误消息是什么?@margo ActionView::MissingTemplate in Posts#index Showing/home/ubuntu/workspace/app/views/Posts/_post.html.haml其中第17行:缺少部分注释/#带有{:locale=>[:en],:formats=>[:html],:variants=>[],:handlers=>[:erb,:builder,:raw,:ruby,:coffee,:haml,:jbuilder]}。搜索:“//主页/ubuntu/workspace/app/views”*“/usr/local/rvm/gems/ruby-2.3.0/gems/designe-4.2.1/app/views”请添加路由文件。错误消息是什么?@margo ActionView::MissingTemplate in Posts#索引显示/home/ubuntu/workspace/app/views/Posts/_post.html.haml,其中第17行出现:缺少部分注释/_注释,带有{:locale=>[:en],:formats=>[:html],:variants=>[],:handlers=>[:erb,:builder,:raw,:ruby,:coffee,:haml,:jbuilder]}。搜索:“/home/ubuntu/workspace/app/views”*“/usr/local/rvm/gems/ruby-2.3.0/gems/devise-4.2.1/app/views”谢谢!我无意中在posts文件夹中有了34; comments.html.haml文件谢谢!我无意中在posts文件夹中有"comments.html.haml文件