を作成していますし、コメントのための私のshowアクションにモーダルレール5未定義のテンプレートエラー
に表示されるshowアクションにコメントを追加します我々はコメント
と一緒にアクションを表示]ボタンをクリックした後、この<%= link_to fetch_selfy_path(selfie.id), class: "show_lightbox", data: { featherlight: "mylightbox" }, remote: true do %>
<img class="card-main-image" src="<%= selfie.photo.url if selfie.photo.url %>" alt="Image Alt text">
<% end %>
<div class="lightbox" id="lightbox">
<%=render partial: "selfies/show", locals: { selfie: selfie } %>
</div>
ようモーダルてショーを得るカント私はAJAXを通じて
addCommentToSelfie("<%= j render "selfies/comments/comment", locals: { comment: @comment } %>");
この戻り、
ActionView::Template::Error (undefined local variable or method `comment' for #<#<Class:0x007f207400c648>:0x00557937265830>):
1:
2: <p> <b><%= comment.user.username %>: </b><%= comment.body %></p>
app/views/selfies/comments/_comment.html.erb:2:in `_app_views_selfies_comments__comment_html_erb__4557429192479440105_46989553619000'
のエラーを新しいcommectを注入しようとするまで
<p> <b><%= comment.user.username %>: </b><%= comment.body %></p>
のような部分的なルックスは、このすべてが正常に動作します
<% selfie.comments.each do |comment| %>
<%= render partial: "selfies/comments/comment", locals: { comment: comment } %>
<% end %>
私は別のメドンドを試しましたが、同じエラーが発生しました
はそれを修正したがスムーズに動作します
そこからまだ#のために同じエラー 'ActionView ::テンプレート::エラー(未定義のローカル変数やメソッド'コメント」を取得<#<クラス: 0x007f207400c648>:0x007f209e0295c0>): 1: 2:
<%= comment.user.username%>:<%= comment。ボディ%>
「 –@geniuskidkanyiああ、私の更新を見てください。 – Iceman
は 'ActionView :: Template :: Error(nil:NilClassの未定義メソッド' user ')を取得しています: ' –