title: missing attribute error Rails
body: <p>I cant seem to get the result of a scope to display in my view as i get this error message.I am trying to get all of the memberships amounts for the day added up and displayed as a total</p>
  
  <pre><code>missing attribute: membership_id
  </code></pre>
  
  <p>My Models and scope</p>
  
  <pre><code>class Member &lt; ActiveRecord::Base
   belongs_to :membership
   accepts_nested_attributes_for :membership
  
   attr_accessible :membership_id, :forename, :middlename, :surname, :house_no, :house_name, :street, :town, :postcode, :home_tel, :mobile_tel, :work_tel, :email, :start_date, :expiry_date
  
  scope :new_memberships_cash_today, -&gt;() {
  joins(:membership).where(:start_date =&gt; Date.today).select('ROUND(SUM(memberships.cost), 2)')
  }
  end
  
  class Membership &lt; ActiveRecord::Base
  has_many :members, :dependent =&gt; :destroy
  attr_accessible :membership_type, :cost 
  end
  </code></pre>
  
  <p>And then my view</p>
  
  <pre><code>columns do
  
    #Total amount in £ for New Memberships today
     column do
      panel "Cash Today", :class =&gt; 'NewAmountMemberships' do
       table_for Member.new_memberships_cash_today  do 
        column 'Total cash' do |c|
         c.membership.map { |e| [e.cost, e.id] }
        end 
       end     
      end
     end
    end
  </code></pre>
  
  <p>After some reading it would seem that there may be an issue with my select call in the scope, as i need to specify all of the models attributes to make a successful call with Active Record? </p>
  
  <p>As i am performing a sum within the select i am unsure how to add more attributes, if this is even the case</p>
  
  <p>Any help appreciated</p>
  
  <p>i have run the scope in the the console and this is what is returned </p>
  
  <pre><code>Member Load (0.1ms)  SELECT ROUND(SUM(memberships.cost), 2) FROM `members` INNER JOIN `memberships` ON `memberships`.`id` = `members`.`membership_id` WHERE `members`.`start_date` = '2013-12-13'
  =&gt; #&lt;ActiveRecord::Relation [#&lt;Member id: nil&gt;]&gt;
  </code></pre>