In the first case, you are calling the sum method on an ActiveRecord
object.
In the second case, you are calling sum on an array of ActiveRecord
objects and as the error message tells you, the sum method is not
defined for Array objects.
The missing piece that you need to know is that when the finders return
more than one ActiveRecord the results are returned in an array of
ActiveRecords.
One question - where would be the best place for the above as far as MVC
goes? Directly in the view or should I be setting a variable to the
above in the controller?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.