-
Type: Bug
-
Resolution: Done
-
Priority: Blocker - P1
-
Affects Version/s: 5.0.0
-
Component/s: None
-
None
-
Environment:railties (4.2.0), mongoid 5.0.0, ruby 2.1.1p76
Given I have the following code
class User include Mongoid::Document scope :author, -> { where(author: true) } end class Article include Mongoid::Document scope :public, -> { where(public: true) } scope :authored, -> { author_ids = User.author.pluck(:id) where(:author_id.in => author_ids) } end
Article.authored.to_a is working as expected:
{"find"=>"users", "filter"=>{"author"=>true}, "projection"=>{"_id"=>1}} {"find"=>"articles", "filter"=>{"author_id"=>{"$in"=>[]}}}
But
Article.public.authored.to_a is not working properly:
{"find"=>"articles", "filter"=>{"public"=>true, "author"=>true}, "projection"=>{"_id"=>1}} {"find"=>"articles", "filter"=>{"public"=>true, "author_id"=>{"$in"=>[]}}}
it turns out that
scope :author, -> { where(author: true) }
is called on Article instead of User
{"find"=>"articles", "filter"=>{"public"=>true, "author"=>true}
- is depended on by
-
MONGOID-4123 Scope merge problem
- Closed