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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:22:06+00:00 2026-06-13T02:22:06+00:00

I have a large and complicated User model that looks something like this: class

  • 0

I have a large and complicated User model that looks something like this:

class User

  class Link
    include DataMapper::Resource
    property :id, Serial, :key => false

    belongs_to :follower, :model => 'User', :key => true
    belongs_to :followed, :model => 'User', :key => true
  end

  include DataMapper::Resource

  property :id, Serial
  property :username, String, :required => true

  has n, :links_to_followers, :model => 'User::Link', :child_key => [:followed_id]
  has n, :links_to_followed, :model => 'User::Link', :child_key => [:follower_id]
  has n, :comments
  has 1, :profile_image
end

My problem is that Datamapper is not letting me Destroy it. I thought this was a result of Datamapper not wanting to destroy an object with un-destroyed child objects so I put in a method destroy_deep that calls destroy on the links_to_followers, links_to_followed, underlying comments, and the profile image (these are all destroyed correctly).

However, even if I call user.destroy after that, the user is not destroyed. There are no error messages of any kind. Is there some kind of cascading delete command that I am missing?

  • 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-06-13T02:22:07+00:00Added an answer on June 13, 2026 at 2:22 am

    I resolved this.

    Apparently to debug destroy, object.errors isn’t useful. Instead track exceptions like:

    begin
      u.destroy
    rescue Exception => e
      p e
    end
    

    The solution was that one of the children fields didn’t map back to User. I had a class Like that belonged to User, but User didn’t have n Likes.

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

Sidebar

Related Questions

OK, so I have a large and complicated upcoming events PHP module that I
My code that I have is quite large and complicated so I won't waste
i have large numbers of text files and i am in problem that i
I have large images displayed in a grouped tableview. I would like the images
I have large video files (~100GB) that are local on my machine. I have
In my application I have large area (≈5000x5000pts) and I must allow user to
I have a large table and allow the user to hide rows based upon
I have a large library of existing powershell scripts, primarily to run some complicated
I have a large, complicated web site, mostly written by other people. I've made
I have code that has a lot of complicated #define error codes that are

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.