Create a virtual attribute in the model that returns the grand total.

def grand_total
  field_1 + field_2 ...
end

You can then reference grand_total from your views like any other
attribute.

On Aug 24, 10:12 am, KR <data...@gmail.com> wrote:
> Total newb here, as I've been working my way threw the tutorial, but
> doing my own thing.
> I've created a fairly simple app, that has a bunch of items.  Each
> item has 6-9 fields that have a cost associated with them (db field =
> float).  Think of each item as a car maintenance log, oil change =
> $50.00, tires = 500, breaks = 230  etc..   I want to be able to add up
> all the fields associated with the item for a grand total.
>
> I've read a lot and I"m not sure if I'm modifying the model, or coming
> up with something fancy in the controller etc..
>
> Any help with my baby steps is much appreciated.
>
> THx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to