Implementing Rate#for's internal logic. #1920

This commit is contained in:
Eric Davis
2009-01-16 16:03:15 -08:00
parent 0d9c7e50de
commit b59c87b1f6
2 changed files with 43 additions and 6 deletions
+8
View File
@@ -26,5 +26,13 @@ class Rate < ActiveRecord::Base
# API to find the Rate for a +user+ on a +project+ at a +date+
def self.for(user, project = nil, date = Date.today.to_s)
rates = Rate.find(:all,
:conditions => ["user_id IN (?) AND project_id IN (?) AND date_in_effect <= ?",
user.id,
project.id,
date
],
:order => 'date_in_effect DESC')
nil
end
end