You can clone with
HTTPS or Subversion.
The documentation says that .unscoped “Returns a scope for the model without the default_scope”, giving the following examples:
Post.all # Fires "SELECT * FROM posts WHERE published = true"
Post.unscoped.all # Fires "SELECT * FROM posts"
However, the following example would also be valid:
Post.where(id: 42).unscoped.all # Fires "SELECT * FROM posts"
Notice how the where condition is removed along with the default scope.
And an example with associations:
class Category < ActiveRecord::Base
category = Category.find(42)
category.posts.all # Fires "SELECT * FROM posts WHERE published = true AND category_id = 42"
category.posts.unscoped.all # Fires "SELECT * FROM posts"
Again, notice how the association information is removed along with the default scope.
I am unsure of whether this is just a documentation issue, or if it is an actual bug.
This would be kind of a documentation issue. unscoped removes all scopes previously defined.
Please feel free to fix the phrasing and open a pull request.
unscope doesn't remove only the default_scope, but all of them.