I want to sum columns.
In my controller
def index
@performance_reports = PerformanceReport.all
end
My error:
undefined method `+' for #<PerformanceReport:0x4a55690>
74: <td><%= @performance_reports.sum(:clicks)%></td>
What is wrong ?
try
in views
basically
PerformanceReport.allwill load whole table and returnArrayofPerformanceReportyou can’t chain queries on Array!!!PerformanceReport.select('*')will returnActiveRecord::Relationand you can chain any AR method on relationi suggest you read rails lazing loading strategy Lazy loading (will_paginate sample) and Rails Query Interface
Awesome Rails