This sounds like a Rails question, and you may want to ask it on a
Rails-specific list; also, its hard to tell what may be going on
without knowing the definition of the objects being used. With the
most intuitive layout of objects for what you seem to be doing, I’d
expect what you are looking for to be something like
current_user.carts.first.items.sum(:unit_price).
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.