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!! -- Posted via http://www.ruby-forum.com/.
On Friday, July 21, 2006, at 12:54 PM, philippogol wrote:>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!! > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsModel.sum(:amount) Look up ''calculations'' in ActiveRecord. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.
ty kevin! and what should i do, to round the number? i have like 10 number aftre the coma. ty!! -- Posted via http://www.ruby-forum.com/.
On Friday, July 21, 2006, at 2:08 PM, philippogol wrote:>ty kevin! > >and what should i do, to round the number? i have like 10 number aftre >the coma. > >ty!! > >-- >Posted via http://www.ruby-forum.com/. >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/rails<%= number_with_precision(@value, 2) %> _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.