title: How to make simple_form do what I want with accepts_nested_attributes_for
body: <p>Each <code>survey</code> <code>has_many</code> <code>results</code>, and <code>accepts_nested_attributes_for</code> <code>results</code>.</p>
  
  <p><strong>/app/models/survey.rb:</strong></p>
  
  <pre><code>attr_accessible :results_attributes
  has_many :results
  accepts_nested_attributes_for :results
  </code></pre>
  
  <p>Each result is either selected or not selected:</p>
  
  <p><strong>/db/schema.rb:</strong></p>
  
  <pre><code>create_table "results", :force =&gt; true do |t|
    t.boolean  "selected", :default =&gt; false
    t.integer "survey_id"
  end
  </code></pre>
  
  <p>Sometimes <code>@survey.additive == true</code>. In those cases, any number of results can be selected. You'd represent this with a series of checkboxes, one for each <code>result</code> in <code>@survey.results</code>.</p>
  
  <p>Sometimes <code>@survey.additive == false</code>. In those cases, only one result can be selected. You'd represent this with a series of radio buttons, one for each <code>result</code> in <code>@survey.results</code>.</p>
  
  <p>I am using <a href="https://github.com/plataformatec/simple_form" rel="nofollow">simple_form</a> and HAML.</p>
  
  <p>I'm trying to write <code>/app/views/surveys/_form.html.haml</code> so that it will create a series of radio buttons to choose which results are selected when <code>@survey.additive == false</code>.</p>
  
  <p>(From there it should be easy to extrapolate the code to also create a series of checkboxes when <code>@survey.additive == true</code>.)</p>
  
  <p>My first attempt was:</p>
  
  <pre><code>= simple_form_for [@competitor, @survey] do |f|
    = f.error_notification
    = f.simple_fields_for :results do |r|
      = r.input :selected, :as =&gt; :radio_buttons, :label =&gt; r.name
    = f.button :submit, :id =&gt; 'submit_survey'
  </code></pre>
  
  <p>That earned me an <code>undefined method 'name' for #&lt;SimpleForm::FormBuilder:0x007fbd1f687048&gt;</code> error.</p>
  
  <p>My second move was removing <code>:label =&gt; r.name</code>, but the result was four separate rows of radio buttons, each row labelled "Selected" and each containing a "Yes" radio button and a "No" radio button. By separate I mean that selecting Yes in one row deselected No in that row but had no affect on the radio buttons in the other rows. (What I actually needed was four connected radio buttons, each labelled after with a <code>result.name</code> in <code>@survey.results</code>, so that deselecting any of the four would deselect the other three.)</p>
  
  <p>After that, I tried many variations, but so far all my attempts have failed. What should I do?</p>