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 4271440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:26:33+00:00 2026-05-21T07:26:33+00:00

Using MongoID and Rails 3… If I store the objectID as a reference to

  • 0

Using MongoID and Rails 3…

If I store the objectID as a reference to an object in my database how do I use it to query the object and return its other properties?

Let’s say my object is:

{ 
 "_id" : ObjectId( "4da0f56ad1f4a901ba455340007" ),
 "name" : "John",
 "age" : "40" 
}

If I had the ObjectId stored in by DB – how would I use it to pull the name or age back to my view? If the object is stored in another model (that doesn’t belong to the view) is there anything else I need to do?

  • 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-05-21T07:26:34+00:00Added an answer on May 21, 2026 at 7:26 am

    Look at database references:

    http://www.mongodb.org/display/DOCS/Database+References

    Otherwise if you have the object id as references stored to another object inside a different collection then your application has to know where the collection is and fetch it from there using another query.

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

Sidebar

Related Questions

I would like to write a query in a Rails model using mongoid, and
I'm using mongoid 3.0 with rails 3.2.3. mongoid.yml looks like: development: sessions: default: database:
I can't seem to find anything to make a date range query using Mongoid/Rails.
I`m having a problem with search query in Rails 3 application using Mongoid. My
I'm trying to use the jQuery token input plugin with Rails and Mongoid. Using
I am using mongoid in rails app. rails 3.0.10 ruby 1.9.2p0 When I am
I have a class User in Rails using Mongoid and Devise. I can't seem
Using Mongoid 2.4.5 on Rails 3.2.1 I have a Model Book that has_many :pages
I am currently working on a rails app where we are using mongoid/mongoDB on
I'm using Mongoid on Sinatra . And I use Dir.glob(File.join(File.dirname(__FILE__),'models','*.rb')).each do |file| require file

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.