module ActiveFedora::Scoping::Default::ClassMethods
def unscoped
Post.unscoped.published
are equal: the +default_scope+ is applied on both.
+published+ is a +scope+, the following two statements
chaining unscoped with +scope+ does not work. Assuming that
It is recommended that you use the block form of unscoped because
}
Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10"
Post.unscoped {
not use the +default_scope+:
This method also accepts a block. All queries inside the block will
Post.unscoped.all # Fires "SELECT * FROM posts"
Post.all # Fires "SELECT * FROM posts WHERE published = true"
end
end
where published: true
def self.default_scope
class Post < ActiveRecord::Base
Returns a scope for the model without the +default_scope+.
def unscoped block_given? ? relation.scoping { yield } : relation end