This project is archived and is in readonly mode.

#1499 ✓resolved
Daniel Luz

find_last (find(:last)) affects other calls on the same scope

Reported by Daniel Luz | December 1st, 2008 @ 01:26 AM | in 2.x

Using find(:last) within a scope leaves side effects on it, affecting all future calls within the same scope.

Pseudocode example:


Book.with_scope(:find => {:order => "id"}) do
  p Book.find(:all)  # returns: 1, 2, 3, 4, 5...
  p Book.find(:last) # returns Book #10
  p Book.find(:all)  # now returns 10, 9, 8, 7...
  p Book.find(:last) # now returns Book #1
end

An ActiveRecord testcase patch is included.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages