Closed HabRonan closed 7 years ago
Did you mean to say donation
instead of donations
inside of the each block?
Otherwise, donations
is a collection of Active Record objects, so you can't just add to it since it's not a number.
@HabRonan
Hey Adrian, It's working now. Used this instead
<p>Amount raised: <%= @project.donations.pluck(:donation_amt).reduce(:+) %></p>
I forgot donations is a collection, I was actually doing
sum: <%= sums += donation.donation_amt %>
and then I went I can just say donations b.c. I can name whatever I want.
Wonderful!
For a Crowdfunding application: I am trying to add each donation: I tried this
but, I am getting: "undefined method `+' for nil:NilClass"