I'm a neophyte in this Ruby, and for an application I'm doing, I need to define a method and a scope to show me the worst rated comments in ascending order: first worst and then improving.
I have written the inverse, thanks to some guidelines of an exercise, however I am not able to make the worst comments. So far I have this scope in my model comment.rb:
scope :rating_desc, -> { order(rating: :desc) }
This method in my model user.rb:
def highest_rating_comment
comments.rating_desc.first
end
And in my show products view this:
<%= @product.highest_rating_comment %>
How should I do to get back the worst results? Thank you very much in advance