私のプロジェクトにはコメントがあり、それらを3つに表示したいのですが、残りのコメントも3つのリンクで表示したいと考えています。ボタンをクリックしたときにコメントを表示し続けるように、部分をレンダリングするにはどうすればよいですか?助けてくれそれぞれ複数のコメントを表示するレール
ポスト/ _comments.html.haml
.container
.row.news
.col-sm-12.news{id: "post-comments-#{post.id}"}
%h2 Users Comments
- post.comments.order(:created_at).last(3).each do |comment|
= render 'posts/comment', comment: comment
.news
%h5 Add a comment:
= form_for [post, post.comments.build], remote: true do |f|
%p
= f.text_area :text
%p
= f.submit
ポスト/ _comment.html.haml
.row.news-coment
.col-sm-2
%img= image_tag comment.user.avatar.url
.col-sm-5
.panel.panel-default
.panel-heading
%strong= link_to("#{comment.user.first_name} #{comment.user.second_name}", user_path(comment.user))
%span.text-muted #{comment.created_at.strftime('%-d %B %Y, %H:%M:%S')}
.panel-body
= comment.text
コメント/ create.js.haml
$("#post-comments-#{@post.id}").append("#{escape_javascript render('posts/comment', comment: @comment)}");
それはすべて私のために設定されています。次の3つのコメントを同じ形式で出力するボタンを追加したいと思います。私はそれをする方法がわからない –
本当に何をしたいのか説明できますか? –
私の英語のために申し訳ありません 私は最後の3つのコメントを表示し、リンクやボタンのクリックに3つのコメントを追加したいと思います。私はすべてまたは3つのコメントを表示することができました。 –