title: Ruby on Rails - Checkbox not saving to database?
body: <p>I've got a migration which uses a boolean value and generates a checkbox in its view.  However, no matter what I click, the value saved to the database is not affected.</p>
  
  <p>My migration looks like this:</p>
  
  <pre><code>def self.up
      create_table :blogposts do |t|
        t.string :title
        t.text :body
        t.boolean :allow_comments, :default =&gt; false  
        t.references :author
        t.references :lasteditor
        t.timestamps
      end
    end
  </code></pre>
  
  <p>My view looks like this:</p>
  
  <pre><code>&lt;% semantic_form_for([:controlpanel, @blogpost]) do |form| %&gt;
  &lt;%= form.error_messages %&gt;
  &lt;% form.inputs do %&gt;
  &lt;%= form.input :title %&gt;
  &lt;%= form.input :body %&gt;
  &lt;%= form.input :allow_comments %&gt;
  &lt;% end %&gt;
  &lt;%= form.buttons %&gt;
  </code></pre>
  
    
  
  <p>Which produces the following HTML:</p>
  
  <pre><code>&lt;li class="boolean required" id="blogpost_allow_comments_input"&gt;
  &lt;label for="blogpost_allow_comments"&gt;
  &lt;input id="blogpost_allow_comments" name="blogpost[allow_comments]" type="checkbox" value="1" /&gt;
  &lt;input name="blogpost[allow_comments]" type="hidden" value="0" /&gt;Allow comments
  &lt;abbr title="required"&gt;*&lt;/abbr&gt;
  &lt;/label&gt;
  &lt;/li&gt; 
  </code></pre>
  
  <p>The controller is just the default generated by the scaffold.</p>
  
  <p>If I set the default in the migration, that value is always saved in the database.  If I do not set a default, it is always NULL.</p>
  
  <p>Can anyone suggest a solution, suggestion on what might be going wrong?</p>
  
  <p>Any advice appreciated.</p>
  
  <p>Thanks.</p>