Skip to content

Instantly share code, notes, and snippets.

@rnmp
Created April 13, 2011 15:57
Show Gist options
  • Save rnmp/917816 to your computer and use it in GitHub Desktop.
Save rnmp/917816 to your computer and use it in GitHub Desktop.
Sums the total time (float)
class Project < ActiveRecord::Base
belongs_to :company
has_many :logs
validates_presence_of :name
def total_hours
total_time = 0
logs.each do |l|
total_time += l.time.to_f
end
total_time
end
end
@xenda
Copy link

xenda commented Apr 13, 2011

Hehe, no problem. Hope it becomes useful next time ;)

@rnmp
Copy link
Author

rnmp commented Apr 13, 2011

It will, really it will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment