title: Rails double Many to many relationship
body: <p>I'm stuck with the UI for the following models, I have three models (badges, sprint, user) and I want to award user with badges but make it sprint dependant. So I have the following model</p>
  
  <p><strong>Badge:</strong></p>
  
  <pre><code>class Badge &lt; ActiveRecord::Base
    has_many :sprint_badges
    has_many :sprints, through: :sprint_badges
  end
  </code></pre>
  
  <p><strong>Sprint</strong></p>
  
  <pre><code>class Sprint &lt; ActiveRecord::Base
    has_and_belongs_to_many :lessons
    has_many :badges, through: :sprint_badges
    has_many :sprint_badges
    belongs_to :group
  end
  </code></pre>
  
  <p><strong>Sprint x Badge</strong></p>
  
  <pre><code>class SprintBadge &lt; ActiveRecord::Base
    belongs_to :sprint
    belongs_to :badge
  
    has_and_belongs_to_many :users
  end
  </code></pre>
  
  <p><strong>User:</strong></p>
  
  <pre><code>class User &lt; ActiveRecord::Base
     has_and_belongs_to_many :sprint_badges
  end
  </code></pre>
  
  <p>So in my user (_form.html.erb) I want to create something like this</p>
  
  <pre><code>Badges   
     sprint1
       checkbox - badge 1
       checkbox - badge 2   
     sprint 2
       checkbox - badge 1
       checkbox - badge 2
  </code></pre>
  
  <p>So I don't know what helper can I use to generate this type of ui form.</p>