Rails3: replace deprecated 'validate' method at CustomField model.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6912 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
dbc616c928
commit
545c4fa6c9
app/models
|
@ -25,6 +25,8 @@ class CustomField < ActiveRecord::Base
|
||||||
validates_length_of :name, :maximum => 30
|
validates_length_of :name, :maximum => 30
|
||||||
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
|
validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats
|
||||||
|
|
||||||
|
validate :validate_values
|
||||||
|
|
||||||
def initialize(attributes = nil)
|
def initialize(attributes = nil)
|
||||||
super
|
super
|
||||||
self.possible_values ||= []
|
self.possible_values ||= []
|
||||||
|
@ -36,7 +38,7 @@ class CustomField < ActiveRecord::Base
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate
|
def validate_values
|
||||||
if self.field_format == "list"
|
if self.field_format == "list"
|
||||||
errors.add(:possible_values, :blank) if self.possible_values.nil? || self.possible_values.empty?
|
errors.add(:possible_values, :blank) if self.possible_values.nil? || self.possible_values.empty?
|
||||||
errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
|
errors.add(:possible_values, :invalid) unless self.possible_values.is_a? Array
|
||||||
|
|
Loading…
Reference in New Issue