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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:36:12+00:00 2026-05-28T01:36:12+00:00

I want to create an app that uses both MongoDB and MySQL. Specifically, I

  • 0

I want to create an app that uses both MongoDB and MySQL. Specifically, I want mongodb to store all the users’ comments while MySQL will store the User model.

class User < ActiveRecord::Base
  has_many :comments
end

class Comment
  include Mongoid::Document
  include Mongoid::Timestamps
  belongs_to :user
end

well, everything looks good except when I go to the rails console and run this.

k = Comment.new
k.user = User.first

I got

NoMethodError: User Load (0.3ms) SELECT users.* FROM users
WHERE users._id = 1 Mysql2::Error: Unknown column ‘users._id’ in
‘where clause’: SELECT users.* FROM users WHERE users._id = 1
undefined method `from_map_or_db’ for

It looks like that the := method is looking for the _id of the model instea of the id? Is there a workaround to get this working automatically or do I need to create my own = method?
Has anyone tried the same configuration before? If so, what are the steps to get all these to work?

  • 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-28T01:36:12+00:00Added an answer on May 28, 2026 at 1:36 am

    This is not gonna work like you want it to. Your belongs_to :user in Comment is telling Mongoid to make this association in MongoDB; in order to make ActiveRecord associations, your class must inherit from ActiveRecord::Base or include ActiveRecord::Model–and you can’t do both!

    Probably the best way to do this–and I don’t know how difficult it would be–is to write your own methods to associate the Users and Comments together.

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

Sidebar

Related Questions

I want to create an App that uses a potentially large xml file. It
I want to create a web app that will use wicket, hibernate and spring
I want to create an app that uses the internet and I'm trying to
I want to create an iPhone app that uses a navigation scene similar to
I want to create a PHP app that can send text messages ; There
I want to create a Facebook app that can operates inside IFrame / FB
I want to create a simple desktop admin application for an IOS app that
I want to create a Qt program that uses the DVB-H headset to watch
I want to create a modular(plugin-like) application that uses JPA as its persistence abstraction,
I’m creating a Django website that uses the bundled auth app to create user

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.