2017-05-13 5 views
0

私はこれを動作させようとしていますが、ページの読み込み時にエラーが表示され、投稿の下にコメントを表示しようとしています。Railsエラーテンプレートがありません(haml)

= render post.comments, post: post 

上の行は、1つの問題の原因とテンプレートは、その呼ばれる_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}" 

コメントは投稿内のネストされたルートです。以下は

.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") 

ルートにレンダリングされるようになっている部分的なファイル_commentです:

Rails.application.routes.draw do 
    devise_for :users, :controllers => { registrations: 'registrations' } 

    resources :posts do 
    resources :comments 
    end 

    root 'posts#index' 

end 

おかげ

+0

ルートファイルを追加できますか? – hashrocket

+0

エラーメッセージは何ですか?ロケール: は{で、部分的なコメント/ _commentがありません:ライン#17を上昇/home/ubuntu/workspace/app/views/posts/_post.html.haml表示投稿で – margo

+0

@margo ActionView :: MissingTemplate#インデックス ハンドラ=> [:erb、:ビルダー、:未処理、:ルビー、:コーヒー、:haml、:jbuilder]}:=> [:en] 。検索対象: * "/ home/ubuntu/workspace/app/views" * "/usr/local/rvm/gems/ruby-2.3.0/gems/devise-4.2.1/app/views" –

答えて

0

私はそれを見る方法、Railsはあなたの_commentsを見つけることができませんが部分的。私はあなたが属していないどこかに置いたと思います。

views 
    comments 
    _comment.html.haml 
    posts 
    _post.html.haml 

_comment.html.hamlコメントフォルダにあることがあります。

ご意見の構造は次のようになります。

+0

ありがとうございました!私は誤って投稿フォルダに_comments.html.hamlファイルを持っていました –

関連する問題