This is driving me nuts with loads of undeclared variables. I have created a simple scaffold with text and integers. How to sum up all integers? See image:
I only want to sum up the "Watts". Im using Rails 4; Ruby 2.1.3
I get this: undefined method 'all' for nil:NilClass
" when I put this code in my app/models/bathroom_accessory.rb
:
def total
@bathroom_accessory.all.sum(&:watts)
end
Have I done something wrong?