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

undefined method `pluck' for #<Mongoid::Contextual::Memory:0x007f9f441f8c78>

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 4.0.0 final
    • Component/s: None
    • Labels:
      None

      Description

      If you have an embedded object, pluck doesn't work. It should. Same in Mongoid 3.x and 4.x.

       ruby
      class Dish
        include Mongoid::Document
      end
       
      class Dinner
        include Mongoid::Document
        embeds_many :dishes
      end
      

      >  Dinner.all.pluck(:id)
      => []
       
      > Dinner.new.dishes.pluck(:id)
      NoMethodError: undefined method `pluck' for #<Mongoid::Contextual::Memory:0x007f80618b9c58>
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/bundler/gems/mongoid-f9e6fdb1a67c/lib/mongoid/contextual.rb:20:in `pluck'
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/bundler/gems/mongoid-f9e6fdb1a67c/lib/mongoid/relations/embedded/many.rb:406:in `public_send'
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/bundler/gems/mongoid-f9e6fdb1a67c/lib/mongoid/relations/embedded/many.rb:406:in `block in method_missing'
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/bundler/gems/mongoid-f9e6fdb1a67c/lib/mongoid/scopable.rb:239:in `with_scope'
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/bundler/gems/mongoid-f9e6fdb1a67c/lib/mongoid/relations/embedded/many.rb:405:in `method_missing'
        from (irb):11
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.1.1/lib/rails/commands/console.rb:90:in `start'
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from /Users/dblock/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
        from script/rails:5:in `require'
        from script/rails:5:in `<main>'
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            dblock Daniel Doubrovkine
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: