title: RoR: Check boxes in form_for for has_many, :through with a Join model
body: <p>Once again, I have my <code>form_for</code> for my <code>Order</code> model, which <code>has_many :services, :through =&gt; :requests</code>.  Here's the layout of how I have my relationships mapped:</p>
  
  <pre><code> __________                               _________
  | Customer |                             | Utility |
   ----------                               ---------
     ||   ^                                     /\
     ||   |                                     ||
     \/   |                                     /\
     _______           _________             _________
    | Order | &lt;=====&lt; | Request |  &gt;=====&gt;  | Service | 
     -------           ---------             ---------
                                                \/
                                                ||
                                                \/
                                             _________  
                                            | Company |
                                             ---------
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>---&gt;                    = belongs_to
  ===&gt;                    = has_many
  &lt;==&lt; join model &gt;==&gt;    = has_many, :through
  </code></pre>
  
  <p>On my Order form, I want to have an array of checkboxes that represent the services available, such that even though the checkboxes are labelled by the <code>Company</code> and categorized by <code>Utility</code>, the <code>Order</code> ends up with the <code>Service</code> association when the order is complete (because that's really what the customer is ordering: a Company to provide a Utility, which is a Service).</p>
  
  <p>How do I accomplish this in my form?</p>
  
  <hr>
  
  <p><strong>form view:</strong></p>
  
  <pre><code>- form_for @order do |order_form| 
    -# order form inputs, etc.
    - order_form.fields_for :customer do |customer_form| 
      -# customer form inputs
    - order_form.fields_for :services do |services_form| 
      %dl
        - @services.each do |service_name, services| 
          %dt= service_name
          - services.each do |service_item| 
            %dd
              =# check_box ??????????
              =# label ??????????, Company.find(service_item.company_id).name
    %p= order_form.submit 'Create Order'
  </code></pre>
  
  <p>Where:</p>
  
  <pre><code>@services = Service.all.to_set.classify { |service_item| Utility.find(service_item.utility_id).name }
  </code></pre>