title: Rails 5 sum and group
body: <p>My DB columns for model Taxline:
  ID, RECEIPT, TAXID, BASE, AMOUNT</p>
  
  <p>Let say I have db entries:</p>
  
  <p>1,1,001,30$,3$</p>
  
  <p>2,1,001,50$,5$</p>
  
  <p>3,2,001,20$,2$</p>
  
  <p>I want to show sum of amount for each receipt. Result should be:</p>
  
  <p>1,8$</p>
  
  <p>2,2$</p>
  
  <p>My controller </p>
  
  <pre><code>    class TaxlinesController &lt; ApplicationController
  
    def index
      @taxlines = Taxline.group(:RECEIPT).sum(:AMOUNT)
    end
  
  end
  </code></pre>
  
  <p>My View:</p>
  
  <pre><code> &lt;% @taxlines.each do |taxline| %&gt;
  
  
          &lt;td&gt;&lt;%= taxline.RECEIPT %&gt;&lt;/td&gt;
          &lt;td&gt;&lt;%= taxline.AMOUNT %&gt;&lt;/td&gt;
  </code></pre>
  
  <p>But I get error undefined method `RECEIPT' for ["01a8fdd7-8eb6-44d0-a686-8010b9e30206", 145000.0]:Array</p>
  
  <p>145000.0 and 01a8fdd7-8eb6-44d0-a686-8010b9e30206 refer to real vaules in db not to the example above. But it gives the idea.</p>
  
  <p>App is built on existing db with column names uppercase.</p>
  
  <p>What am I doing wrong?</p>