diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-05 17:44:15 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-05 17:44:15 +0000 |
commit | 73dba2ac044f9ff5de1917fd2457fd1a7b3f3377 (patch) | |
tree | 8ec8a0c78d11565ede2e1e15715b65cf7c326ed1 /app/models/issue.rb | |
parent | fd7910efc9e2620b77028153bb7a34fc4e66c4a7 (diff) | |
download | redmine-73dba2ac044f9ff5de1917fd2457fd1a7b3f3377.tar.gz redmine-73dba2ac044f9ff5de1917fd2457fd1a7b3f3377.zip |
Added default value for enumerations.
Only default issue priority is actually used.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@803 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/issue.rb')
-rw-r--r-- | app/models/issue.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 7d214de8a..52e21b416 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -46,9 +46,17 @@ class Issue < ActiveRecord::Base validates_numericality_of :estimated_hours, :allow_nil => true validates_associated :custom_values, :on => :update - # set default status for new issues - def before_validation - self.status = IssueStatus.default if status.nil? + def after_initialize + if new_record? + # set default values for new records only + self.status ||= IssueStatus.default + self.priority ||= Enumeration.default('IPRI') + end + end + + def priority_id=(pid) + self.priority = nil + write_attribute(:priority_id, pid) end def validate |