Skip to content

Instantly share code, notes, and snippets.

@rnmp
Created April 13, 2011 15:57
Show Gist options
  • Select an option

  • Save rnmp/917816 to your computer and use it in GitHub Desktop.

Select an option

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
@rnmp

rnmp commented Apr 13, 2011

Copy link
Copy Markdown
Author

Nice, thanks! But I won't change it in order to register the contrast. :)

@xenda

xenda commented Apr 13, 2011

Copy link
Copy Markdown

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

@rnmp

rnmp commented Apr 13, 2011

Copy link
Copy Markdown
Author

It will, really it will.

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