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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:13:01+00:00 2026-05-30T16:13:01+00:00

OK, just got: class User include Mongoid::Document # devise stuff… has_one :card end class

  • 0

OK, just got:

class User
  include Mongoid::Document
  # devise stuff...
  has_one :card
end

class Card
  include Mongoid::Document

  belongs_to :user
end


irb(main):012:0> user = User.new(email: "test@test.com", password: "testtest",password_confirmation: "testtest")
=> #<User _id: 4f4e1b1494b3023d34000003, _type: nil, email: "test@test.com", encrypted_password: "$2a$10$yCdmjfgK94VrIec062ZXFuoTuApFFaFsDSOVEutoklcSGc4SQH2MG", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil>
irb(main):013:0> user.build_card uuid: "test"
=> #<Card _id: 4f4e1b2094b3023d34000004, _type: nil, created_at: nil, updated_at: nil, uuid: "test", user_id: BSON::ObjectId('4f4e1b1494b3023d34000003')>
irb(main):014:0> user.new_record?
=> true
irb(main):015:0> user.card.new_record?
=> true
irb(main):016:0> user.save
=> true
irb(main):017:0> user.card.new_record?
=> true
irb(main):018:0> User.count
=> 1
irb(main):019:0> Card.count
=> 0

Thanks!

  • 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-30T16:13:03+00:00Added an answer on May 30, 2026 at 4:13 pm

    OK I need to use

    has_one :card, autosave: true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my irb session: irb(main):001:0> class User irb(main):002:1> include MongoMapper::Document irb(main):003:1> key :name, String
We just got our first major Perl CGI assignment in my CS class. Our
I've got a simple model object: class UserRating include MongoMapper::EmbeddedDocument key :idea_id, ObjectId key
Lets say I have a class User. A user got a name, gender, ...,
Just got a request from my boss for an application I'm working on. Basically
Just got a question about generics, why doesn't this compile when using a generic
I just got Delphi 2009 and have previously read some articles about modifications that
I just got a dedicated server from a hosting company, and for some reason,
I just got through manually removing the bin\ and obj\ folders from around 30
I just got a shiny, brand-new Debian server handed to me by our Systems

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.