-2
的號碼,我想算我的頁面調用視圖顯示項目
在這裏評論的數量是我CONTROLER代碼
def view
@gallery = Gallery.find_by!(id: params[:id]).decorate
@comments = Comment.select(:user_id, :description).includes(:user).where(gallery_id: @gallery.id)
if user_signed_in?
@like = current_user.likes.where(gallery_id: @gallery.id).first
end
end
這是視圖頁面
.text-container
p: strong Komentar
- @comments.each do |comment|
.media.testimoni-box
.col-md-12.jaminan
.media-heading.strong = comment.user_personal_name
= comment.description
- # want to show the number of comment here
請幫助我。並感謝提前
感謝您的回答。它的工作,當我把下面= comment.descrption。但如果我把文字容器放在外面怎麼辦?我的意思是總評論 –
@LukniBurhanuddinAhmad'@ comments.count'得到總數 – Andrei
就像@Andrei說的。只是addd'= @ comments.count'嵌套到'.text-container' – sa77