title: Rails: How to use sum and multiple models to get the total order value
body: <p>I would like to display <code>@amount_spent</code> and <code>@amount_received</code> by each user. I've already finished the first part with <code>@amount_spent = Reservation.where(user_id: @user.id).sum(:total)</code></p>
  <p>Now I would also like to display the <code>@amount_received</code>, since I use Stripe Connect.</p>
  <p>I've tried something similar to:</p>
  <pre><code>@user = User.find(params[:id])
  @products = @user.products
  @amount_received = @products.reservations.sum(:total)
  </code></pre>
  <p>But when I try to use <code>reservations</code> with <code>@products</code> I get an <code>#&lt;Product::ActiveRecord_Associations_CollectionProxy:0x00007f50b8709fa8&gt;</code> error.</p>
  <p>Is there a better way or another way, probably with scopes?</p>
  <h3>User Model:</h3>
  <pre><code>has_many :products
  has_many :reservations
  </code></pre>
  <h3>Product Model:</h3>
  <pre><code>has_many :reservations
  </code></pre>
  <h3>Reservation Model:</h3>
  <pre><code>belongs_to :user
  belongs_to :product
  </code></pre>