This project is archived and is in readonly mode.
find_last (find(:last)) affects other calls on the same scope
-
Daniel Luz
- Tag changed from 2.1-stable, 2.2-stable, :order, activerecord, bug, find_last, named_scope, scope, with_scope to 2.1-stable, 2.2-stable, :order, activerecord, bug, find_last, named_scope, patch, scope, with_scope
Patch altering the way
#find_lastworks with scoped_methods.Rather than updating all elements on the stack, update just the current scope, and restore its state afterward.
-
Daniel Luz
- Title changed from find_last (find(:last)) affects other calls on the same scope to [PATCH] find_last (find(:last)) affects other calls on the same scope
-
Chris Kampmeier
+1, nice catch.
Tried it out, looks good. Tests are great; patch fixes the problem, although I don't know enough about method scoping to know if there's a better way to do it. This one looks fine, though.
p.s. if you merge those into one patch formatted with
git format-patch, it makes it way easier to apply (and commit on your behalf). Directions here. Otherwise, git doesn't know who wrote the patch, thinks it's an uncommitted change, etc. -
Daniel Luz
Testcase and fix in a single patch.
They were separated because at first I didn't have a solution, so I just came here to leave a report and a test case. After some more fiddling I had a better understanding of how the scoping works and came up with this patch.
-
Pratik
- Assigned user set to Pratik
- Title changed from [PATCH] find_last (find(:last)) affects other calls on the same scope to find_last (find(:last)) affects other calls on the same scope
-
Repository
- State changed from new to resolved
(from [f7bd0beb67c5d9d50e37aa596605b91e61197fbe]) Ensure Model#last doesn't affects order for another finders inside the same scope [#1499 find_last (find(:last)) affects other calls on the same scope state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...
