Description
It's nice to restore previous scope in `.with_scope`, don't you think?
diff --git a/lib/mongoid/scopable.rb b/lib/mongoid/scopable.rb
|
index 76887e78a..7b4f55331 100644 |
--- a/lib/mongoid/scopable.rb
|
+++ b/lib/mongoid/scopable.rb
|
@@ -226,11 +226,12 @@ module Mongoid |
#
|
# @since 1.0.0 |
def with_scope(criteria)
|
+ previous = Threaded.current_scope(self)
|
Threaded.set_current_scope(criteria, self)
|
begin
|
yield criteria
|
ensure
|
- Threaded.set_current_scope(nil, self)
|
+ Threaded.set_current_scope(previous, self)
|
end
|
end
|
|
Attachments
Issue Links
- is cloned by
-
MONGOID-5229 Add Feature Flag: .with_scope should restore previous scope
-
- Closed
-
- is related to
-
MONGOID-5215 Document that or/nor conditions make default scope one of the disjunction branches
-
- Closed
-
-
MONGOID-5214 Make unscoped clear current scope or document that it does not
-
- Closed
-
- links to