title: RoR extend ActiveRecord::relation with undestroy_all
body: <p>I basically want to the following function, but in the reverse, and i already have the <code>undestroy</code> function working for single classes.</p>
  
  <p><a href="https://github.com/rails/rails/blob/2ad168ee41d590bd9a4d15eddf3c2f719c23b60a/activerecord/lib/active_record/relation.rb#L364" rel="nofollow">https://github.com/rails/rails/blob/2ad168ee41d590bd9a4d15eddf3c2f719c23b60a/activerecord/lib/active_record/relation.rb#L364</a></p>
  
  <p>However, I am trying to to extend ActiveRecord::Relation to no avail. Here's how i do it for other methods by for <code>ActiveRecord::Base</code></p>
  
  <p><code>ActiveRecord::Base.extend Track::BaseTrack</code></p>
  
  <p>But using <code>ActiveRecord::Relation.extend Track::TrackRelation</code> doesn't seem to do anything. The module <code>TrackRelation</code> (inside <code>Track</code>) is:</p>
  
  <pre><code>  module TrackRelation
  
        def undestroy_all(conditions = nil)
          if conditions
            where(conditions).undestroy_all
          else
            to_a.each {|object| object.undestroy }.tap { reset }
          end
        end
  
    end
  </code></pre>
  
  <p>Am I using the correct ActiveRecord class for relations? </p>
  
  <p>The error is:</p>
  
  <p><code>undefined method "undestroy_all" for #&lt;ActiveRecord::Relation []&gt;</code></p>