samedi 22 juillet 2017

Ruby - Count comment

I want to count the number of comment on my page called view

here is my controler code

  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

this is view page

  .text-container
    p: strong Komentar
    - @comments.each do |comment|
      = render :partial => comment
      .media.testimoni-box
        .col-md-12.jaminan
          .media-heading.strong = comment.user_personal_name
          = comment.description
    ---->I want to show the number of comment here

Please help me. and thanks for advance

Aucun commentaire:

Enregistrer un commentaire