<% for shift in @shifts %>
now I want to add the sum of Work time/Day in to new field when i create
what is that command
<% for shift in @shifts %>
now I want to add the sum of Work time/Day in to new field when i create
what is that command
On Thu, Feb 19, 2009 at 5:17 AM, MaD [email protected] wrote:
puts sum
Also, you should be able to do the following:
sum = rows.inject(0) { | sum, row | sum + row.value }
Good luck,
-Conrad
to be honest, i don’t really understand what you are trying to do, but
if you just want to build a sum to put it into some field:
initialize a variable with 0 (outside of your for-loop) and add any
value you want to that variable.
sum = 0
rows.each do |row|
sum += row.value
end
puts sum
from “<%= (shift.end - shift.start)/100 %>” mean work time per day
now i want to add the sum of Total work time i to new field
i’m newbie for ROR please tell me step by step , thank you .
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs