title: Button add/remove to collection rails
body: <p>i'm currently trying to use the associations between groups and cows, and I would like to built a button for this association. To explain the situation, we're into the "<em>show group</em>" and it will display a button for each cows. And if the user click on a button, it will create an association between the curent group and the cow.</p>
  
  <p>Actually there is no errors, but the association is not working </p>
  
  <p>My code : </p>
  
  <p>Group_controller :</p>
  
  <pre><code>before_action :set_group      
  
  def add_asso
   @cow = Cow.find_by(params[:id])
   @group.cows &lt;&lt; @cow
   redirect_to :back
  end
  </code></pre>
  
  <p>Show group : </p>
  
  <pre><code>&lt;% @ranch = @group.ranch %&gt;
  &lt;% @cows = @ranch.cows %&gt;
  
  &lt;%  @cows.each do |c| %&gt;
    &lt;%- if @group.cows.exists?(c.id) %&gt;
      &lt;%= link_to add_asso_group_path(@group.id, c.id), method: :post do %&gt;
      &lt;div class="btn btn-success"&gt;
          &lt;%= c.name%&gt;
      &lt;/div&gt;
      &lt;% end %&gt;
      &lt;% else %&gt;
      &lt;div class="btn btn-info"&gt;
          &lt;%= c.name%&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  &lt;% end %&gt;
  &lt;%= link_to 'Back', groups_path %&gt;
  </code></pre>
  
  <p>And finally my routes :</p>
  
  <pre><code>resources :groups do 
      member do 
        post :add_asso
        post :rem_asso
      end
    end 
  </code></pre>
  
  <p>So if you have any advices about how to run this association, you'll be my HERO !!</p>