title: Rails - How to calculate "you beat xx% of users on score"
body: <p>Say I have a user model:</p>
  
  <pre><code>    class User &lt; ActiveRecord::Base
  
      end
  </code></pre>
  
  <p>and an answer model:</p>
  
  <pre><code>    class Answer &lt; ActiveRecord::Base
        belongs_to :user
  
      end
  </code></pre>
  
  <p>To encourage users to give out more answers, I want to show for a specific user what is his/her rank in all users. (Ranking is based on the number of answers he/she gives out)</p>
  
  <p>I don't want to create a ranking board due to privacy issue. I only want to return a message of "you beat xx% of users in the number of answers given out". </p>
  
  <p>I have a rough idea that is to do a group by and get the rank number for this user, but I am not sure how should I make it as efficient as possible. </p>