Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Misleading documentation for ActiveRecord::Scoping::Default.unscoped #14294
The documentation says that
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
And an example with associations:
class Category < ActiveRecord::Base has_many :posts end 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.