title: Rails 3: validate presence of at least one has many through association item
body: <p>I have two models: <code>Project</code> and <code>ProjectDiscipline</code>:</p>
  
  <pre><code>class Project &lt; ActiveRecord::Base
    has_many :project_disciplinizations, :dependent =&gt; :destroy
    has_many :project_disciplines, through: :project_disciplinizations
    attr_accessible :project_discipline_ids
    attr_accessible :project_disciplines_attributes
    accepts_nested_attributes_for :project_disciplines, :reject_if =&gt; proc { |attributes| attributes['name'].blank? }
  end
  
  class ProjectDiscipline &lt; ActiveRecord::Base
    attr_accessible :name
    has_many :project_disciplinizations, :dependent =&gt; :destroy
    has_many :projects, through: :project_disciplinizations
  end
  
  class ProjectDisciplinization &lt; ActiveRecord::Base
    attr_accessible :project_discipline_id, :project_id
    belongs_to :project_discipline
    belongs_to :project
  end
  </code></pre>
  
  <p>On the new/edit <code>Project</code> form, I have a list of disciplines and a check box for each one of them so users can pick disciplines:</p>
  
  <pre><code>&lt;div class="control-group"&gt;
    &lt;label class="control-label"&gt;Check disciplines that apply&lt;/label&gt;
    &lt;div class="controls"&gt;
      &lt;%= f.collection_check_boxes(:project_discipline_ids, ProjectDiscipline.order('name'), :id, :name, {}, {:class =&gt; 'checkbox'}) {|input| input.label(:class =&gt; 'checkbox') { input.check_box + input.text }} %&gt;
      &lt;p class="help-block"&gt;You must choose at least one discipline.&lt;/p&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to add a validation to require that at least one discipline is checked. I've tried but I haven't figured out yet. How can I add this validation?</p>