title: How can I remove and return the first element in an ActiveRecord relation object?
body: <p>I want to remove and return the first element in an AR relation object. I used <a href="http://ruby-doc.org/core-1.9.3/Array.html#method-i-shift" rel="nofollow">shift</a>, but it does not remove the object.</p>
  
  <p>With a normal array, shift works as expected:</p>
  
  <pre><code>a = [1, 2, 3]
  a.shift # =&gt; 1
  a # =&gt; [2, 3]
  </code></pre>
  
  <p>This does not work. The variable <code>@attachment_versions</code> retains the same size before and after using <code>shift</code>.</p>
  
  <pre><code>@attachment = Attachment.with_associations.find(params[:id])
  @attachment_versions = @attachment.attachment_versions
  @current_version = @attachment_versions.shift
  
  # this raises `true`
  raise @attachment_versions.include?(@current_version).to_s
  
  def self.with_associations
    includes(attachment_versions: :owner, comments: [:author, :attachments])
  end
  </code></pre>
  
  <p>I know that an AR relation object is more than just an Array, but I thought <code>shift</code> should work in the same way.</p>