title: Many to Many AND habtm-checkboxes help needed!
body: <p>For some reason nothing is getting stored in my groups_user table below is the info.</p>
  
  <p>My Models</p>
  
  <p>group.rb</p>
  
  <pre><code>class Group &lt; ActiveRecord::Base
    has_and_belongs_to_many :users
  end
  </code></pre>
  
  <p>user.rb</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    has_and_belongs_to_many :groups
  end
  </code></pre>
  
  <p>groups_user.rb</p>
  
  <pre><code>class GroupsUser &lt; ActiveRecord::Base
  end
  </code></pre>
  
  <p>The Entity Relationship Diagram</p>
  
  <p><a href="https://i.imgur.com/MqWok.png" rel="nofollow noreferrer">http://i.imgur.com/MqWok.png</a></p>
  
  <p>The Form</p>
  
  <p><a href="https://i.imgur.com/BwwaV.png" rel="nofollow noreferrer">http://i.imgur.com/BwwaV.png</a></p>
  
  <p>The view code</p>
  
  <pre><code>&lt;% for group in @groups %&gt;
      &lt;%= check_box_tag "user[group_ids][]", group.id, @user.groups.include?(group) %&gt;
      &lt;%= group.description %&gt;
      &lt;% end %&gt;
  </code></pre>
  
  <p>users_controller.rb</p>
  
  <pre><code>def update 
    @user = User.find(params[:id]) 
    params[:user][:group_ids] ||= [] 
    if @user.update_attributes(params[:user]) flash[:success] = "User updated." 
      redirect_to @user #end 
    else 
      @title = "Edit user" 
      render 'edit' 
    end 
  end
  </code></pre>