Skip to content

Instantly share code, notes, and snippets.

@abuiles
Created August 3, 2010 21:10
Show Gist options
  • Save abuiles/507160 to your computer and use it in GitHub Desktop.
Save abuiles/507160 to your computer and use it in GitHub Desktop.
def self.average_task_price(identifier,account)
tasks = Task.find(:all, :conditions => {:identifier => identifier , :account_id => account.id})
size = tasks.size
if size > 0
totalPrice = completions.inject(0) {|val, tasks| val + task.price.to_f }
total/size.to_f
else
0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment