Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1357

default_scope + any_in scope fails

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.3.3
    • Affects Version/s: None
    • Component/s: None

      require 'mongoid'
      Mongoid.configure do |config|
        config.master = Mongo::Connection.new.db("foo_#{Time.now.to_i}")
      end
      
      class Project
        include Mongoid::Document
      
        field :name
        field :state, :default => 'active'
      
        # Comment 1 line and it works, both fails:
        default_scope where(:state => 'active')
        scope :inactive, any_in(:state => [:done, :wip])
      
      end
      
      NoMethodError: undefined method `has_key?' for "active":String
          from /usr/lib/ruby/gems/1.9.1/gems/mongoid-2.3.2/lib/mongoid/criteria.rb:402:in `block (2 levels) in update_selector'
          from /usr/lib/ruby/gems/1.9.1/gems/mongoid-2.3.2/lib/mongoid/criteria.rb:398:in `each_pair'
          from /usr/lib/ruby/gems/1.9.1/gems/mongoid-2.3.2/lib/mongoid/criteria.rb:398:in `block in update_selector'
          from /usr/lib/ruby/gems/1.9.1/gems/mongoid-2.3.2/lib/mongoid/criteria.rb:396:in `tap'
          from /usr/lib/ruby/gems/1.9.1/gems/mongoid-2.3.2/lib/mongoid/criteria.rb:396:in `update_selector'
          from /usr/lib/ruby/gems/1.9.1/gems/mongoid-2.3.2/lib/mongoid/criterion/inclusion.rb:184:in `in'
          from /usr/lib/ruby/gems/1.9.1/gems/mongoid-2.3.2/lib/mongoid/finders.rb:15:in `any_in'
      
      

      If I run only the default_scope line it works, only the scope line works. Both don't.

      asaaki was who found this out:

      https://github.com/nofxx/symbolize/issues/15

            Assignee:
            Unassigned Unassigned
            Reporter:
            nofxx Marcos
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: