<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -40,12 +40,14 @@ class SmerfAnswer &lt; SmerfItem
     super(parent_id, sort_order_field)
     
     @fields = {
-      'code'                      =&gt; {'mandatory' =&gt; 'Y'},
+      'code'                      =&gt; {'mandatory' =&gt; 'Y', 'field_method' =&gt; 'code_to_s'},
       'answer'                    =&gt; {'mandatory' =&gt; 'Y'},
       'default'                   =&gt; {'mandatory' =&gt; 'Y'},
       'sort_order'                =&gt; {'mandatory' =&gt; 'Y'},
       'subquestions'              =&gt; {'mandatory' =&gt; 'N', 'child_items' =&gt; 'SmerfQuestion', 'sort_by' =&gt; 'sort_order'}
     }  
   end
+
+  protected
     
 end</diff>
      <filename>app/models/smerf_answer.rb</filename>
    </modified>
    <modified>
      <diff>@@ -33,7 +33,7 @@ class SmerfGroup &lt; SmerfItem
 
     # Define group fields
     @fields = {
-      'code'                      =&gt; {'mandatory' =&gt; 'Y'},
+      'code'                      =&gt; {'mandatory' =&gt; 'Y', 'field_method' =&gt; 'code_to_s'},
       'name'                      =&gt; {'mandatory' =&gt; 'Y'},
       'questions'                 =&gt; {'mandatory' =&gt; 'Y', 'child_items' =&gt; 'SmerfQuestion', 'sort_by' =&gt; 'sort_order'},
       'description'               =&gt; {'mandatory' =&gt; 'N'}</diff>
      <filename>app/models/smerf_group.rb</filename>
    </modified>
    <modified>
      <diff>@@ -265,5 +265,14 @@ class SmerfItem
       remove_instance_variable(:@unique_code_check)       
       remove_instance_variable(:@fields)
     end
+
+    protected
+
+    # Store codes as a string, if we don't then numeric codes
+    # will have problems as we do comparisons with responsed pulled
+    # directly from the http request where all codes are strings.
+    def code_to_s
+      @code = @code.to_s
+    end
     
 end</diff>
      <filename>app/models/smerf_item.rb</filename>
    </modified>
    <modified>
      <diff>@@ -69,7 +69,7 @@ class SmerfQuestion &lt; SmerfItem
     super(parent_id, sort_order_field)
     
     @fields = {
-      'code'                        =&gt; {'mandatory' =&gt; 'Y'},
+      'code'                        =&gt; {'mandatory' =&gt; 'Y', 'field_method' =&gt; 'code_to_s'},
       'type'                        =&gt; {'mandatory' =&gt; 'Y', 'field_method' =&gt; 'check_question_type'},
       'question'                    =&gt; {'mandatory' =&gt; 'N'},
       'sort_order'                  =&gt; {'mandatory' =&gt; 'Y'},</diff>
      <filename>app/models/smerf_question.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>529697aa0c23d73a17fa737c2e2964a36d6b6875</id>
    </parent>
  </parents>
  <author>
    <name>Etienne van Tonder</name>
    <email>etiennevt@gmail.com</email>
  </author>
  <url>http://github.com/springbok/smerf/commit/9be23171633eaa8fbb4723a03af48cb72c9797cd</url>
  <id>9be23171633eaa8fbb4723a03af48cb72c9797cd</id>
  <committed-date>2009-05-07T20:21:14-07:00</committed-date>
  <authored-date>2009-05-07T20:21:14-07:00</authored-date>
  <message>Bug fix: As per the bug reported by bgoodwin. SMERF now correctly handles numeric question codes. Previously if a numeric question code was used the validation functions did not work correctly as it was trying to access the responses hash extracted directly from the HTTP request using a numeric key when all the keys in the responses hash are strings. SMERF will now convert numeric codes to a string before saving to the DB.</message>
  <tree>b487b3f69154690ab8ddda3b6ff0ef4914e38c9b</tree>
  <committer>
    <name>Etienne van Tonder</name>
    <email>etiennevt@gmail.com</email>
  </committer>
</commit>
