Displaying most popular posts on my blog - Ruby on Rails
- by bgadoci
I have created a simple blog application using Ruby on Rails, both of which I am new to. I am trying to get my most 'voted' posts to display in my /views/posts/index.html.erb view. Here are the basics.
I have created a votes table and successfully allow a user to 'vote' for a post on the /views/posts/show.html.erb page. When they vote, it passes '1' to the votes table and I return the vote count via ajax to the same show page. Vote belongs_to :post and Post has_many :votes.
I would like to display in /views/posts/index.html.erb the post title and the amount of times it has been voted for, ordered by posts with the highest vote count.
Any ideas on how to do this?