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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:55:05+00:00 2026-05-18T21:55:05+00:00

I had this working fine yesterday, made some changes and I have no idea

  • 0

I had this working fine yesterday, made some changes and I have no idea how I broke it. I’m sure it’s a typo somewhere, but I cannot see it.

Any changes made to the nested model in the form are just not being saved at all, the development log shows the attributes going through – and they appear to be in the right format, but it’s just not updating at all.

I have a User model which references_one Biography like so:

# app/models/user.rb
class User
  include Mongoid::Document
  include Mongoid::Timestamps

  field :first_name, :type => String
  field :last_name, :type => String
  devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable

  references_one :biography

  accepts_nested_attributes_for :biography
  #--snip---
end

# app/models/biography.rb
class Biography
  include Mongoid::Document
  include Mongoid::Timestamps

  field :content, :type => String
  field :role, :type => String
  field :is_crew, :type => Boolean

  referenced_in :user
end

And finally my form (i’m using simple form here, but for the most part it behaves very similar to formtastic):

<%= simple_form_for [:manage, @user], :html => {:multipart => true}, :position => :left do |f| %>
  <h2>Login details</h2>
  <%= f.input :email, :input_html => {:class => "text"} %>      
  <%= f.input :first_name, :input_html => {:class => "text"} %>
  <%= f.input :last_name, :input_html => {:class => "text"} %>

  <div class="biography">
    <h2>Biography</h2>
    <%= f.simple_fields_for :biography do |biography_form| %>
      <%= biography_form.input :role, :input_html => {:class => "text"} %>
      <%= biography_form.input :content, :as => :text, :input_html => {:class => "textarea"} %>
      <%= biography_form.input :is_crew, :as => :boolean %>
    <%- end -%>
  </div>

  <%= f.submit "Save user", :class => "submit mid" %>
<% end %>

And some output from my development log, incase the answers lie there, and I just cant see them:

    Started POST "/manage/users/john-doe" for 127.0.0.1 at Wed Dec 15 11:42:09 +1100 2010
      Processing by Manage::UsersController#update as HTML
      Parameters: {"commit"=>"Save user", "authenticity_token"=>"44QlHsbKb8Pm91wnxWJa8Y0QsUXDzp/3rVpfs3G1Inc=", "utf8"=>"✓", "id"=>"john-doe", "user"=>{"biography_attributes"=>{"is_crew"=>"0", "role"=>"Tenor", "id"=>"4d080de56a4f1dfe7700000e", "content"=>"John was born on the 1st of January, 1970."}, "last_name"=>"Doe", "first_name"=>"Johnathan", "email"=>"testing@involved.com.au"}}
    the_idea_of_north_development['users'].find({:_id=>BSON::ObjectId('4d06e6036a4f1dcb1b000001')}, {}).limit(-1)
    the_idea_of_north_development['users'].find({:slug=>"john-doe"}, {}).limit(-1)
    the_idea_of_north_development['biographies'].find({"user_id"=>BSON::ObjectId('4d080de06a4f1dfe7700000d')}, {}).limit(-1)
    the_idea_of_north_development['$cmd'].find({"count"=>"users", "query"=>{:_id=>{"$ne"=>BSON::ObjectId('4d080de06a4f1dfe7700000d')}, :email=>/^testing@involved\.com\.au$/i}, "fields"=>nil}, {}).limit(-1)
    the_idea_of_north_development['users'].find({"slug"=>"johnathan-doe"}, {})
    MONGODB the_idea_of_north_development['users'].update({"_id"=>BSON::ObjectId('4d080de06a4f1dfe7700000d')}, {"$set"=>{"slug"=>"johnathan-doe", "updated_at"=>Wed Dec 15 00:42:09 UTC 2010, "first_name"=>"Johnathan"}})
    Redirected to http://lvh.me:3000/manage/users
    Completed 302 Found in 17ms

Any changes to the User model update fine, but changes to the Biography are unsaved. Help me hive-mind, you’re my only hope!

  • 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-18T21:55:06+00:00Added an answer on May 18, 2026 at 9:55 pm

    I’ve been having a similar problem with changes to nested documents not being persisted. (The question is How Do I Update Nested Mongo Document Attributes in Rails with Mongoid?). I’m suspicious of Mongoid itself because a message like the following is never logged for updating the embedded document:

    MONGODB the_idea_of_north_development['users'].update({"_id"=>BSON::ObjectId('4d080de06a4f1dfe7700000d')}, {"$set"=>{"slug"=>"johnathan-doe", "updated_at"=>Wed Dec 15 00:42:09 UTC 2010, "first_name"=>"Johnathan"}})
    

    If an attempt was being made to make an update to the nested document, there would be a line similar to that one selecting the parent document and setting the nested document’s values, such as:

    the_idea_of_north_development['users'].update({"_id"=>PARENT_DOCUMENT}, {"$set"=>{"biography_attributes.is_crew"=>"0", "biography_attribute.role"=>"Tenor", etc...})
    

    Personally, I find Mongoid Issue #357 a possible reason.

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

Sidebar

Related Questions

I had this idea of creating a count down timer, like 01:02, on the
This might seem obvious but I've had this error when trying to use LINQ
We've had this question already, but I want to narrow it down to already
I had this question earlier and it was concluded it was a bug in
I had this answer on another post I asked: I believe the VS designer
I've had this long term issue in not quite understanding how to implement a
I've had this problem many times before, and I've never had a solution I
I've had this problem a couple of times. Let's say I want to display
(Jeopardy-style question, I wish the answer had been online when I had this issue)
I had someting like this in my code (.Net 2.0, MS SQL) SqlConnection connection

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.