Require that a Rate be unlocked before saving it. #1919

This commit is contained in:
Eric Davis
2009-01-16 15:28:34 -08:00
parent 9b0332bf78
commit 3ffb31fafc
2 changed files with 36 additions and 0 deletions
+6
View File
@@ -6,6 +6,8 @@ class Rate < ActiveRecord::Base
validates_presence_of :user_id
validates_presence_of :date_in_effect
before_save :unlocked?
named_scope :history_for_user, lambda { |user|
{
:conditions => { :user_id => user.id },
@@ -16,4 +18,8 @@ class Rate < ActiveRecord::Base
def locked?
return self.time_entries.length > 0
end
def unlocked?
return !self.locked?
end
end