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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:22:32+00:00 2026-05-22T18:22:32+00:00

I can read my database using Mongoid, but cannot write to it. This example

  • 0

I can read my database using Mongoid, but cannot write to it.

This example below successfully outputs the activity’s device type, but it crashes on the save method with this error message: “undefined method `name’ for nil:NilClass“

        activity = Activity.find('4d89568d4f21557eb10003fc')
        puts activity.deviceType
        activity.description = 'my description'
        activity.save

Here are my class definitions:

class User
    include Mongoid::Document
    field :name, :type => String
    field :identifier, :type => String
    field :email, :type => String
    referenced_in :activity
end

class Trackpoint
    include Mongoid::Document
    field :when, :type => DateTime
    field :latitude, :type => Float
    field :longitude, :type => Float
    field :distance, :type => Float
    field :altitude, :type => Float
    field :heartRate, :type => Integer
    embedded_in :activity, :inverse_of => :trackpoint
end

class Activity
    include Mongoid::Document
    field :startTime, :type => DateTime
    field :description, :type => String
    field :sport, :type => String
    field :deviceType, :type => String
    field :deviceId, :type => String
    field :deviceActivityId, :type => String
    field :isPublic, :type => Boolean
    field :user_id, :type => String
    embeds_many :trackpoints
    references_one :user
end

Thanks for any help…

  • 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-22T18:22:33+00:00Added an answer on May 22, 2026 at 6:22 pm

    Just got rid of the :inverse_of statements and it works now!

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

Sidebar

Related Questions

I created a SQLite database on Android device. The program can read/write to database
I can read unmanaged memory in C# using UnmanagedMemoryStream, but how can I do
I can read settings like this, for example: final String mytest = System.getString(this.getContentResolver(), System.AIRPLANE_MODE_ON);
I'm trying to read and store an RSS feed in my database using this
I'm trying to read a .doc file into a database so that I can
I can read the MySQL documentation and it's pretty clear. But, how does one
You can read this question where I ask about the best architecture for a
In .Net you can read a string value into another data type using either
I'm using the JDBC template and want to read from a database using prepared
I'm using R to read some data from a MySQL database using the RODBC

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.