aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-08-06 18:20:35 +0200
committerJoachim Filip Ignacy Bartosik <jbartosik@gmail.com>2010-08-09 18:01:06 +0200
commitde786f350786a22e96a028f141d819d0bf574528 (patch)
treee65f3a783e2d8a462901831f5ea9f4e0a6e973a2 /lib
parentAdd :null => false to required fields and relations in models. (diff)
downloadrecruiting-webapp-de786f350786a22e96a028f141d819d0bf574528.tar.gz
recruiting-webapp-de786f350786a22e96a028f141d819d0bf574528.tar.bz2
recruiting-webapp-de786f350786a22e96a028f141d819d0bf574528.zip
Bugfix - previous commit was tested unproperly and introduced some bugs
Answer can't enforce :null=>false on content field of answer because when user answers multiple choice question and selects no options his/her answer will have empty content field.
Diffstat (limited to 'lib')
-rw-r--r--lib/rich_types/check_list.rb10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/rich_types/check_list.rb b/lib/rich_types/check_list.rb
index fe8986b..57510a6 100644
--- a/lib/rich_types/check_list.rb
+++ b/lib/rich_types/check_list.rb
@@ -32,7 +32,7 @@ module RichTypes
elsif klass == String
# Convert to Array and use = for Arrays
- self.options = what.split(',').inject(Array.new){|r, c| r.push c.to_i}
+ self.options = YAML::load(what)
elsif klass == NilClass
for i in @opt_list.keys
@@ -42,11 +42,9 @@ module RichTypes
end
def to_s
- result = ""
- for i in @opt_list.keys
- result += i.to_s + "," if @opt_list[i][:checked]
- end
- result.chop
+ selected = @opt_list.collect{ |x| x[0] if x[1][:checked] }
+ selected = selected.flatten.uniq.compact.sort
+ selected.to_yaml.strip
end
protected