Home How to delete all associated records of Specific record using loop? (not Using dependent)
Reply: 0

How to delete all associated records of Specific record using loop? (not Using dependent)

user4893
1#
user4893 Published in September 19, 2018, 9:46 am

How to delete all associated records of Specific record using a loop? like When I will delete one Specific Seller at that time their related record should be deleted. eg. when One Seller is deleted that time their Products, Customer, SellerMarketplace should be deleted.(Not Marketplace should be deleted.)

class Seller < ActiveRecord::Base
    has_many :products
    has_many :customers
    has_many :seller_marketplaces
    has_many :marketplaces through: :seller_marketplaces
end
share|improve this question
  • I think you need to set the association for seller_marketplaces as well – Deepak Mahakale Apr 12 at 6:25

2 Answers 2

active oldest votes
up vote 1 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.310535 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO