Skip to content

Instantly share code, notes, and snippets.

@edavis10
Created January 22, 2009 21:58
Show Gist options
  • Save edavis10/50744 to your computer and use it in GitHub Desktop.
Save edavis10/50744 to your computer and use it in GitHub Desktop.
# My jQuery thinking is starting to bleed into Ruby
def amount_for_user(user=nil)
return 0 if self.time_entries.size <= 0
return self.time_entries.select do |time_entry|
user.nil? || time_entry.user == user
end.collect(&:cost).compact.sum
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment