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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:09:41+00:00 2026-06-07T04:09:41+00:00

I am a newbie and would appreciate some help on how to resolve this

  • 0

I am a newbie and would appreciate some help on how to resolve this problem. I have tried to follow the documentation in DataMapper and have not found any solutions via Google on how to destroy an object and its corresponding links. Here are the key code segments.

The Model

class Entity

include DataMapper::Resource

property :entity_id, Serial
property :full_legal_name, String
property :tax_id, String
property :phone_number, String
property :fax_number, String
property :cell_number, String
property :email, String, :unique => true, :format => :email_address
property :alt_email, String
property :is_active, Boolean
property :created_at, DateTime
property :created_by, String
property :updated_at, DateTime
property :updated_by, String
property :auto_pay, Boolean
property :use_ach, Boolean
property :prefix, String
property :first_name, String
property :middle_name, String
property :last_name, String
property :suffix, String
property :referral_code, String
property :login_name, String, :unique => true
property :hashed_password, String, :length => 200
property :salt, String
property :permission_level, Integer
property :title, String
property :greeting, String
property :preferred_name, String
property :preferred_language, String
property :security_question, String
property :security_answer, String
property :signature_font, String
property :auth1_checkbox, Boolean
property :auth2_checkbox, Boolean
property :auth3_checkbox, Boolean
property :auth4_checkbox, Boolean
property :auth5_checkbox, Boolean
property :auth6_checkbox, Boolean
property :digital_signature, String
property :date_signed, DateTime
property :signatory_ip, String
property :signatory_title, String

has n, :addresses, :through => Resource
has n, :aches
has n, :creditcards

end

class Person < Entity

property :birthdate, String
property :drivers_license_number, String
property :state_issuing_drivers_license, String

end

class Company < Entity

property :dba_name, String
property :legal_structure, String
property :url, String, :format => :url

end

class Address

include DataMapper::Resource

property :address_id, Serial
property :esid, String, :unique => true
property :description, String
property :address_line1, String
property :address_line2, String
property :city, String
property :state, String
property :zipcode, String
property :country, String
property :meter_number, String
property :meter_type, String
property :meter_status, String
property :meter_status_date, DateTime
property :updated_by, String
property :switch_indicator, String
property :switch_type, String
property :selected_switch_date, Date
property :under_contract, Boolean
property :contract_end_date, Date

has n, :entities, :through => Resource

end

Object creation and Persistence

     if session[:base_route].to_s == "residential"
   #residential processing
   @entity_id = session[:this_person].inspect
   @person = Person.get(@entity_id.to_i)
   @address = Address.new()
   @address.esid = params[:post][:esid]
   @address.description = params[:post][:service_location_description]
   @address.address_line1 = params[:post][:service_address_line1]
   @address.address_line2 = params[:post][:service_address_line2]
   @address.city = params[:post][:service_city_name]
   @address.state = params[:post][:service_state_name]
   @address.zipcode = params[:post][:service_zip_code]
   @address.switch_indicator = params[:post][:switch_indicator]
   @address.switch_type = params[:post][:switch_type]
   params[:post][:under_contract_checkbox]  == "on" ? @under_contract = true : @under_contract = false 
   @address.under_contract = @under_contract

   @person.addresses << @address

   if @person.save

Attempted object and link destruction (The link is destroyed, but the address destruction does not work)

    @entity_id = session[:this_person].inspect
    address = Address.get(params[:post][:submit].to_i)
    address.destroy
    entity = Entity.get(@entity_id)
    link = entity.address_entities.get(@entity_id, params[:post][:submit])
    link.destroy      

Any tips or suggestions are greatly appreciated.

  • 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-07T04:09:43+00:00Added an answer on June 7, 2026 at 4:09 am

    The deletion of the answer object failed because there was a link between the answer object and the entity object. By reversing the order and deleting the link first and the object second, the object is destroyed.

    @entity_id = session[:this_person].inspect
    entity = Entity.get(@entity_id)
    link = entity.address_entities.get(@entity_id, params[:post][:submit])
    link.destroy
    address = Address.get(params[:post][:submit].to_i)
    address.destroy
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a newbie in Spring Batch, and I would appreciate some help to resolve
Would really appreciate some help with this. I have an app which consists of
Im a javascript newbie and would need some help with this simple thing... I
Newbie and would really appreciate some help rendering objects in sets of 3's. I
I am a newbie in Matlab, so I would appreciate your help! I have
I am a newbie to Serial Port Analysis and I would appreciate some help
Would appreciate any help to a newbie here. I have a simple if/else if
Im still a newbie in android, would appreciate your help as I couldnt find
I'm relatively a newbie, would appreciate help :) I am looking to find entry(ies)
I'm a javascript newbie so please, any help would be appreciate. I've been trying

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.