これは私の最初のRailsアプリを完成させるための最後の残りのアイテムであり、いくつかの助けが必要です。各ユーザープロファイル(localhost:3000 / users / username)には、ユーザーが行った投稿のリストがあります。各投稿に関連付けられているのはコメントです。したがって、post_id:3にコメントを付けることができます。
すでにビューフォームで機能していますが、各投稿の下にある[コメント]リンクをクリックしたときに、代わりにポップアップにコメントを表示する必要があります。ポップアップを表示するjQueryベースのライトボックスであるfaceboxをすでに適用しました。
現在show.html.erbに表示されているものをポップアップに移動する必要があります。
_post.html.erbにレンダリングされる_comment_form.html.erbがあります
<%= link_to #, :rel => "facebox-#{post.id}" do %>
+<%= post.comments.count.to_s %>
<% end %>
<div class ="ItemComments"><% if post.comments.exists? %>
<% post.comments.each do |comment| %>
<%= image_tag("http://www.gravatar.com/avatar.php?gravatar_id=#{Digest::MD5::hexdigest(comment.user.email)}" %>
<span class="users"><%= link_to comment.user.name, comment.user %></span>
<span class="timestamp"><%= time_ago_in_words(comment.created_at) %> ago</span>
<span class="content2"><%= comment.comment_content %></span>
<% end %>
<% end %></div>
上記は、以下を使用して_post.html.erbにレンダリングされます。
<%= render 'shared/comment_form', post: post if signed_in?%>
次に、show.html.erbにレンダリングします
この行を使用しようとしていますが、何にリンクしますか?
<%= link_to #, :rel => "facebox-#{post.id}" do %>
+<%= post.comments.count.to_s %>
<% end %>
これはshared/_comment.html.erbです
<% if post.comments.exists? %>
<% post.comments.each do |comment| %>
<%= image_tag("http://www.gravatar.com/avatar.php?gravatar") %>
<%= link_to comment.user.name, comment.user %>
<span class="timestamp"><%= time_ago_in_words(comment.created_at) %> ago</span>
<span class="content2"><%= comment.comment_content %></span>
<% end %>
<% end %>