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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:33:55+00:00 2026-05-25T13:33:55+00:00

I have a routine action that creates an comment object, where an answer has_many

  • 0

I have a routine action that creates an comment object, where an answer has_many comments.

I am experiencing a weird bug that occasionally deletes the existing comments for an answer when a new comment is posted to that answer. The new comment gets deleted as well.

MongoHQ kindly directed me to this issue: https://github.com/mongoid/mongoid/issues/1173, but i am using mongoid2.2, which is supposed not to have this issue.

class Answer
  include Mongoid::Document
  has_many :comments, :dependent => :delete

class Comment
  include Mongoid::Document
  belongs_to :answer

# answer controller
def comment
  answer=Answer.find(params[:id])
  c=Comment.new(:text=>params[:text],:user_id=>current_user.id,:answer_id=>answer.id)
  success=c.save

  respond_to do |format|
    format.json {
        render :json=>c.to_json
      else
        render :json=>{"failure"=>c.errors}.to_json
      end
    }
  end    
end

More details included here:
http://pastie.org/2488895

  • 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-25T13:33:56+00:00Added an answer on May 25, 2026 at 1:33 pm

    I fixed it by downgrading to mongoid 2.0.2. This seems to be a very specific bug that only happens under a 1-N relationship, and if you are on mongohq. Hope it gets fixed in mongoid >2.2

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

Sidebar

Related Questions

I have a javascript routine that is performing actions on a group of checkboxes,
I have this routine that calculates the seconds-to-date for a struct tm . On
I have a routine that examines thousands of records looking for discrepancies. This can
I have a routine that dynamically changes a select list's selected option when the
I have a little routine that's run under Linux and Windows written in C
Hi I have some cron jobs that to routine maintenance tasks, I was wondering
I have a page containing a Chart object that I use as the default
I am attempting to route a URL that does not have a static action
I have an action called List that shows the results of a search. It
I have a form that is suppose to be a POST to CREATE action

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.