Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9200051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:40:46+00:00 2026-06-17T22:40:46+00:00

I have a class method Juxtaposition.generate_for(position) on a class that I am calling from

  • 0

I have a class method Juxtaposition.generate_for(position) on a class that I am calling from a spec. The method sets up a map reduce and calls it map_reduce(map, reduce).out(merge: "juxtapositions")

The position variable is defined in a let prior to the it block.

When executing if I simply call the function above (which is really only calling a map reduce on data related to the position) then tests like below fail:

Juxtaposition.count.should eq 1
Juxtaposition.first.value.should eq values

However, if I call

Juxtaposition.generate_for(positions).first["value"].should eq values

prior to the two tests then they both pass. The above two tests also pass when I use pry and call the generate_for method from there.

Is there some strange behavior of map reduce in mongoid that I should be aware of? Or, is there some way to force the results into my later queries.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:40:47+00:00Added an answer on June 17, 2026 at 10:40 pm

    Solution was simple enough. I just need to make sure to call find on the call to map reduce.

    More specifically:

    map_reduce(map, reduce).out(merge: "juxtapositions").first
    

    or

    map_reduce(map, reduce).out(merge: "juxtapositions").to_a
    

    Without to_a or first the actual map reduce doesn’t execute it seems, even if it’s meant to be stored in another collection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that contains this class method: def self.get_event_record(row, participant) event =
I have a template class method like that: template<class T> static tmpClass<T>* MakeInstance(T value)
I have a C# class method that return a xml document not file. How
Assume that I have a particular class of object that defines a class method
i have bug that i cannot find, i have Class Point with method who
I have a class with some method that depend by one parameter. What is
I have a class whereby a method calls a nested class. I want to
I have class method that returns a list of employees that I can iterate
I have a class method that deals with dates: public function setAvailability(DateTime $start, DateTime
I have a class method on User, that returns applies a complicated select /

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.