diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-04 17:04:50 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-04 17:04:50 +0000 |
commit | c216ab325bc56123819fb5b700a759753959ead8 (patch) | |
tree | a90493432ae7a2ca681c193e65627d16341bf53e /app/models/enumeration.rb | |
parent | 479b9b54336c3fa5ce3f9fccb56307a52b48dd0c (diff) | |
download | redmine-c216ab325bc56123819fb5b700a759753959ead8.tar.gz redmine-c216ab325bc56123819fb5b700a759753959ead8.zip |
Added position on Enumeration model.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@800 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/enumeration.rb')
-rw-r--r-- | app/models/enumeration.rb | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index 46d350a21..b0ad48bc7 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -16,27 +16,33 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Enumeration < ActiveRecord::Base + acts_as_list :scope => 'opt = \'#{opt}\'' + before_destroy :check_integrity validates_presence_of :opt, :name validates_uniqueness_of :name, :scope => [:opt] validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\'\-]*$/i - - OPTIONS = { - "IPRI" => :enumeration_issue_priorities, - "DCAT" => :enumeration_doc_categories, - "ACTI" => :enumeration_activities - }.freeze - - def self.get_values(option) - find(:all, :conditions => ['opt=?', option]) - end - + + OPTIONS = { + "IPRI" => :enumeration_issue_priorities, + "DCAT" => :enumeration_doc_categories, + "ACTI" => :enumeration_activities + }.freeze + + def self.get_values(option) + find(:all, :conditions => {:opt => option}, :order => 'position') + end + def option_name OPTIONS[self.opt] end + #def <=>(enumeration) + # position <=> enumeration.position + #end + def to_s; name end private |