title: How to remove something from a collection
body: <p>I have a Rails app with a User.rb model that has a many to many relationship with a Practice.rb model (which might be a bad name for the model) For example, a user might work in several different practice areas (such as 'karate' and 'judo'), which I seeded the database with. There is a situation where I wish to reduce the number of practices a user has (user has a maximum of two) and therefore I do this inside a method in one of the models in order to remove the second practice</p>
  
  <pre><code>      if user.practices.size &gt; 1
          user.practices[1].destroy
        end 
  </code></pre>
  
  <p>However, the result is that it's not only removing that practice (for example, 'karate') from the <code>user.practices</code>, but destroying the practice out of existence, such that 'karate' is no longer listed in the available practices for anyone. If I do <code>Practice.all</code> 'karate' will not appear. </p>
  
  <p>The same thing happens if I use <code>'delete'</code> instead of <code>'destroy.'</code></p>
  
  <p>user.practices yields a CollectionProxy</p>
  
  <p>
  
  <p>What is the proper way to remove it from the <code>user.practices</code> without removing it totally from <code>Practice.all</code> </p>
  
  <p>Update</p>
  
  <p>The model set up is like this. Ideally when I remove the practice from the user, the relevant practice_listing would also be deleted. </p>
  
  <pre><code>User.rb
  
  has_many :practice_listings
    has_many :practices, through: :practice_listings
  
  Practice.rb
   has_many :practice_listings
    has_many :users, through: :practice_listings
  
  PracticeListing.rb
  
  belongs_to :practice
  belongs_to :user
  </code></pre>