Use #read/#write_attribute instead of #super when overwriting default accessors (#16319).

Patch by Felix Schäfer.

git-svn-id: http://svn.redmine.org/redmine/trunk@12968 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2014-03-15 10:25:24 +00:00
parent 1547119627
commit d7729d6d4f
1 changed files with 3 additions and 2 deletions

View File

@ -114,7 +114,7 @@ class CustomField < ActiveRecord::Base
end
def possible_values
values = super()
values = read_attribute(:possible_values)
if values.is_a?(Array)
values.each do |value|
value.force_encoding('UTF-8') if value.respond_to?(:force_encoding)
@ -128,7 +128,8 @@ class CustomField < ActiveRecord::Base
# Makes possible_values accept a multiline string
def possible_values=(arg)
if arg.is_a?(Array)
super(arg.compact.collect(&:strip).select {|v| !v.blank?})
values = arg.compact.collect(&:strip).select {|v| !v.blank?}
write_attribute(:possible_values, values)
else
self.possible_values = arg.to_s.split(/[\n\r]+/)
end