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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:09:52+00:00 2026-05-27T04:09:52+00:00

I have some rails application with MongoDB, Mongoid mapper and devise. Аuthorized user can

  • 0

I have some rails application with MongoDB, Mongoid mapper and devise. Аuthorized user can create, edit, delete post(scaffold) and comment this posts. I take for comment model example of Ryan Bates screencasts, 238 episode “Mongoid”.

comment.rb

class Comment
  include Mongoid::Document
  field :name
  field :content
  embedded_in :post, :inverse_of => :comments
end

post.rb

class Post
      include Mongoid::Document
      field :name
      field :content
      validates_presence_of :name
      embeds_many :comments
    end

user.rb

class User
  include Mongoid::Document
  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
    :recoverable, :rememberable, :trackable, :validatable

  field :username

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me

  has_many :comments
  references_many :post

end

But when I try to register new user, in registration form push “Sign up”, I see this error

Mongoid::Errors::MixedRelations in Devise::RegistrationsController#create

Referencing a(n) Comment document from the User document via a relational association is not allowed since the Comment is embedded.

I start this apllication with Mysql db, and then decided to move into mongo.
Where is my mistake?

  • 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-27T04:09:52+00:00Added an answer on May 27, 2026 at 4:09 am

    Since Comment is embedded in Post you should have User referencing Post. Try removing has_many :comments in User.

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

Sidebar

Related Questions

I am working on a rails application (I have some experience with rails). But,
I'm looking at building a Rails application which will have some pretty large tables
I'm working on a Rails application where I have some a set of two
i have some action in my rails application def show @issue = Issue.find(params[:id], :include
I have a Rails application using Restful authentication and declarative authorization. I have some
I have a Rails application but after some time of development/debugging I realized that
In my Rails application, I have a variety of database tables that contain user
I have a SharePoint server. I am building an rails application which can interact
I have a Rails application with several models-views-controllers which have some similar characteristics, for
I have a rails application in which I implemented some feature. Now I want

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.