Adding numbers

hi! how can i add all the values from one tables field? i mean, i have a
table with the entries of a booking (amount), and at the end, i want to
have the total.

i tried with different loops making a method in the model, but nothing.
im doing something wrong, but i dont know what.

please could somebody help me?

ty!!

On Friday, July 21, 2006, at 12:54 PM, philippogol wrote:


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Model.sum(:amount)

Look up ‘calculations’ in ActiveRecord.

_Kevin
www.sciwerks.com

ty kevin!

and what should i do, to round the number? i have like 10 number aftre
the coma.

ty!!

On Friday, July 21, 2006, at 2:08 PM, philippogol wrote:

Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

<%= number_with_precision(@value, 2) %>

_Kevin
www.sciwerks.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs