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

  • SEARCH
  • Home
  • 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 8308203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:43:51+00:00 2026-06-08T18:43:51+00:00

Using Rails 3.2, and Mongoid 2.4. I have a legacy model, Organization, that embeds_many

  • 0

Using Rails 3.2, and Mongoid 2.4. I have a legacy model, Organization, that embeds_many organization_members. It looks something like this:

class Organization
  include Mongoid::Document

  embeds_many :organization_members
end

class OrganizationMembers
  include Mongoid::Document
  embedded_in :organization
end

What I’d like to do is change the method I use to access members from organization.organization_members to just organization.members. Here’s what I’ve done:

class Organization
  include Mongoid::Document

  embeds_many :members, class_name:"OrganizationMember"
end

class OrganizationMembers
  include Mongoid::Document
  embedded_in :organization
end

However, now organization.members returns an empty array and organization.organization_members returns the previous documents, even though it church_members isn’t defined.

How do I persuade Mongoid to use the previous embedded collection name and access it through the new method call (Organization#members not Organization#organization_members)?

  • 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-08T18:43:53+00:00Added an answer on June 8, 2026 at 6:43 pm

    There’s an option to embeds_many, called store_as.

    class Organization
      include Mongoid::Document
    
      embeds_many :members, 
                  class_name:"OrganizationMember", 
                  store_as: 'organization_members'
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Mongoid 2.4.5 on Rails 3.2.1 I have a Model Book that has_many :pages
I have a class User in Rails using Mongoid and Devise. I can't seem
I would like to write a query in a Rails model using mongoid, and
I have a model in a Rails/Mongoid application that I had initially set a
Using: Rails 3.1.1 I have a controller/model/view called Category that is built up on
I've got a Ruby on Rails app that is using MongoDB for datastorage. Mongoid::Timestamp
I have recently been getting my feet wet in MongoDB using Mongoid w/ Rails
I recently played with MongoDB in Rails using Mongoid . I like the ability
I have two entities, projects and users. These are modeled in Rails using Mongoid
I'm using Mongoid, Devise and Rails 3.1. I have four models: Students, Teacher, Parents

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.