[#4604] Clear and recalculate the #cost on Rate#save

This commit is contained in:
Eric Davis
2010-10-06 13:05:57 -07:00
parent d656121b20
commit f7b03b825f
3 changed files with 38 additions and 1 deletions
+5
View File
@@ -11,6 +11,7 @@ class Rate < ActiveRecord::Base
validates_numericality_of :amount
before_save :unlocked?
after_save :update_time_entry_cost_cache
before_destroy :unlocked?
named_scope :history_for_user, lambda { |user, order|
@@ -36,6 +37,10 @@ class Rate < ActiveRecord::Base
def specific?
return !self.default?
end
def update_time_entry_cost_cache
TimeEntry.update_cost_cache(user, project)
end
# 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)