KR 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 -could- do it this way:

Table item
... list of items

Table work_done
... list of things done

Table work_done_on_items
... item_id and work_done_id

And you could then just run a simple query for the sum of all the things 
associated with that item.. Or if you really wanted to, put the 'total' 
in the 'item' table and then you'd have to do "on_change" on the other 
table so it updates the total every time an item is added, removed, or 
changed...

hope this helps.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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