title: virtual attribute in a query
body: <p>User model has <strong>all_scores</strong> attribute and i created the method below </p>
  
  <p>models/user.rb </p>
  
  <pre><code>def score
    ActiveSupport::JSON.decode(self.all_scores)["local"]
  end
  </code></pre>
  
  <p>What i'm trying to do this using this virtual attribute score to filter users. For example:
  I need the users whose score is over 50.  The problem is i can't use virtual attribute as a regular attribute in a query.</p>
  
  <pre><code>User.where("score &gt; 50") # i can't do this.
  </code></pre>
  
  <p>Any help will be appreciated.</p>