I'm trying to show the comment with the highest rating in the product show page but it shows # instead of the comment. Any ideas why?
#comment model
class Comment < ApplicationRecord
belongs_to :user
belongs_to :product
scope :rating_desc, -> { order(rating: :desc) }
scope :rating_asc, -> { order(rating: :asc) }
end
#product model
class Product < ApplicationRecord
has_many :orders
has_many :comments
def highest_rating_comment
comments.rating_desc.first
end
end
#product show page
<%= @product.highest_rating_comment %>