title: Rails 5: validation of acceptance for a checkbox
body: <p>I have a sign-up form with some nested fields, and inside this form I have added a checkbox for the terms of service.</p>
  
  <p>I'm trying to validate when the checkbox is checked or not and return an error if not. </p>
  
  <pre><code> validates_acceptance_of :agreement, :allow_nil =&gt; true, :accept =&gt; true, :on =&gt; :create
  </code></pre>
  
  <p>I do have a boolean column that is set to default inside the accounts table.</p>
  
  <pre><code>add_column :accounts, :agreement, :boolean, default: false
  </code></pre>
  
  <p>Also, I have added the <code>:agreement</code> to the permitted controller params.</p>
  
  <p>This is the form:</p>
  
  <pre><code>   &lt;%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %&gt;
      &lt;div class="centerList"&gt;
        &lt;div id="error_explanation"&gt;
          &lt;%= devise_error_messages! %&gt;&lt;/div&gt;
      &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;span class="asterisk_input"&gt;&lt;/span&gt;
          &lt;%= f.email_field :email, autofocus: true, placeholder: "email", :class=&gt;"form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;span class="asterisk_input"&gt;&lt;/span&gt;
          &lt;%= f.password_field :password, placeholder: "password", autocomplete: "off", :class=&gt;"form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;span class="asterisk_input"&gt;&lt;/span&gt;
          &lt;%= f.password_field :password_confirmation, placeholder: "confirm password", autocomplete: "off", :class=&gt;"form-control"  %&gt;
        &lt;/div&gt;
  
        &lt;%= f.fields_for :account do |form| %&gt;
  
  
        &lt;div class="form-group"&gt;
          &lt;span class="asterisk_input"&gt;&lt;/span&gt;
          &lt;%= form.text_field :street, placeholder: "street", :class=&gt;"form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;span class="asterisk_input"&gt;&lt;/span&gt;
          &lt;%= form.text_field :city, placeholder: "city", :class=&gt;"form-control"  %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;span class="asterisk_input"&gt;&lt;/span&gt;
          &lt;%= form.text_field :state, placeholder: "state", :class=&gt;"form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;span class="asterisk_input"&gt;&lt;/span&gt;
          &lt;%= form.text_field :zip_code, placeholder: "zip code", :class=&gt;"form-control" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
          &lt;span class="asterisk_input"&gt;&lt;/span&gt;
          &lt;%= form.country_select :country, ["US"], {}, { :class =&gt; "form-control", :id=&gt;"sign-frm-input" } %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group"&gt;
            &lt;%= form.check_box :agreement %&gt; I agree to the &lt;%= link_to 'Terms', term_path(:id=&gt;1) %&gt;.
        &lt;/div&gt;
  
  &lt;% end %&gt;
        &lt;div class="form-group"&gt;
          &lt;%= f.submit "Sign up", :class=&gt;'btn btn-primary' %&gt;
    &lt;% end %&gt;
  </code></pre>
  
  <p>But it returns the form error <code>agreement must be accepted</code> even if I do accept it. Any ideas what I might be missing ohere!</p>