Rails 4 Error: NoMethodError - undefined method
<p>I am struggling ordering my loop through my Devise Users by the upvotes on <code>tools</code> created by them.</p>

<p>Inside of that loop I get the value I would like to use to order the elments with:</p>

<pre><code>user.tools.map(&amp;:cached_votes_up).sum
</code></pre>

<p>That's my loop:</p>

<pre><code>- @users.order(user.tools.map(&amp;:cached_votes_up).sum).each do |user| #incorrect!
</code></pre>

<p>And my controller:</p>

<pre><code>@users = User.all
</code></pre>

<p>Without <code>order</code> in my loop everything runs fine, with it this error appears:</p>

<pre><code>NoMethodError in Users#index
Showing c:/Users/Jonas/gitapps/ocubit/app/views/users/index.html.haml where line #21 raised:

undefined method `tools' for #&lt;Class:0xac2db78&gt;
</code></pre>

<p>I am grateful for each help!</p>