From b127f9157d456f233b320b349b415844eb632cb9 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 9 Dec 2011 22:58:30 +0000 Subject: Resourcified custom fields. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8144 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/custom_field.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'app/models') diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 0ad8b4ce0..93e662785 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -155,6 +155,22 @@ class CustomField < ActiveRecord::Base find(:all, :conditions => ["is_for_all=?", true], :order => 'position') end + # Returns an instance of the given subclass name + def self.new_subclass_instance(class_name, *args) + klass = nil + begin + klass = class_name.to_s.classify.constantize + rescue + # invalid class name + end + unless subclasses.include? klass + klass = nil + end + if klass + klass.new(*args) + end + end + def type_name nil end -- cgit v1.2.3