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/enumeration.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/enumeration.rb')
-rw-r--r-- | app/models/enumeration.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index b0ad48bc7..744bc1a88 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -34,14 +34,18 @@ class Enumeration < ActiveRecord::Base def self.get_values(option) find(:all, :conditions => {:opt => option}, :order => 'position') end + + def self.default(option) + find(:first, :conditions => {:opt => option, :is_default => true}, :order => 'position') + end def option_name OPTIONS[self.opt] end - - #def <=>(enumeration) - # position <=> enumeration.position - #end + + def before_save + Enumeration.update_all("is_default = #{connection.quoted_false}", {:opt => opt}) if is_default? + end def to_s; name end |