Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

unscope now works on default_scope after 94924dc

  • Loading branch information...
commit 4d7080f80c1ec4792730943b33b6eac2a1562b2a 1 parent 0944792
@rafaelfranca rafaelfranca authored
View
13 activerecord/CHANGELOG.md
@@ -1,12 +1,15 @@
+* `.unscope` now removes conditions specified in `default_scope`.
+
+ *Jon Leighton*
+
* Extend ActiveRecord::Base#cache_key to take an optional list of timestamp attributes of which the highest will be used.
- Example:
-
- # last_reviewed_at will be used, if that's more recent than updated_at, or vice versa
- Person.find(5).cache_key(:updated_at, :last_reviewed_at)
+ Example:
- *DHH*
+ # last_reviewed_at will be used, if that's more recent than updated_at, or vice versa
+ Person.find(5).cache_key(:updated_at, :last_reviewed_at)
+ *DHH*
* Added ActiveRecord::Base#enum for declaring enum attributes where the values map to integers in the database, but can be queried by name.
View
3  activerecord/lib/active_record/relation/query_methods.rb
@@ -341,9 +341,6 @@ def reorder!(*args) # :nodoc:
# User.where(name: "John", active: true).unscope(where: :name)
# == User.where(active: true)
#
- # This method is applied before the default_scope is applied. So the conditions
- # specified in default_scope will not be removed.
- #
# Note that this method is more generalized than ActiveRecord::SpawnMethods#except
# because #except will only affect a particular relation's values. It won't wipe
# the order, grouping, etc. when that relation is merged. For example:
View
2  activerecord/test/cases/scoping/default_scoping_test.rb
@@ -103,7 +103,7 @@ def test_order_after_reorder_combines_orders
def test_unscope_overrides_default_scope
expected = Developer.all.collect { |dev| [dev.name, dev.id] }
- received = Developer.order('name ASC, id DESC').unscope(:order).collect { |dev| [dev.name, dev.id] }
+ received = DeveloperCalledJamis.unscope(:where).collect { |dev| [dev.name, dev.id] }
assert_equal expected, received
end

1 comment on commit 4d7080f

@dhh
Owner

This is over-promising a bit until we have it working for associations too.

Please sign in to comment.
Something went wrong with that request. Please try again.