Refactored Rate#for_user_project_and_date to allow nil projects. #1920

This commit is contained in:
Eric Davis
2009-01-16 16:34:38 -08:00
parent 4599e21dfb
commit da891cc607
2 changed files with 30 additions and 1 deletions
+6 -1
View File
@@ -34,14 +34,19 @@ class Rate < ActiveRecord::Base
private
def self.for_user_project_and_date(user, project, date)
project_id = project.nil? ? nil : project.id
return Rate.find(:first,
:order => 'date_in_effect DESC',
:conditions => [
"user_id IN (?) AND project_id IN (?) AND date_in_effect <= ?",
user.id,
project.id,
project_id,
date
])
end
def self.for_user_and_date(user, date)
self.for_user_project_and_date(user, nil, date)
end
end