unscoped does not work when chained with named_scope
This commit is contained in:
parent
b587bfd589
commit
13ebf69ae4
@ -876,6 +876,11 @@ def arel_engine
|
||||
# limit(10) # Fires "SELECT * FROM posts LIMIT 10"
|
||||
# }
|
||||
#
|
||||
# It is recommended to use block form of unscoped because chaining unscoped with <tt>named_scope</tt>
|
||||
# does not work. Assuming that <tt>published</tt> is a <tt>named_scope</tt> following two statements are same.
|
||||
#
|
||||
# Post.unscoped.published
|
||||
# Post.published
|
||||
def unscoped
|
||||
block_given? ? relation.scoping { yield } : relation
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user