krishna krishna - 4 months ago 32
Ruby Question

Rails dependent destroy and really destroy an acts_aS_paranoid object

I have two models articles and bookmarks. Both are defined as acts_as_paranoid objects. Relationship between them is


has_many :bookmarks, foreign_key: 'article_doi', primary_key: 'doi', dependent: :destroy


belongs_to :article, foreign_key: 'article_doi', primary_key: 'doi'

Now I want to really remove a bookmark object and also remove the dependent bookmarks objects.


and checked


did not remove the article or its bookmarks. How can I really remove them from the database and its associated bookmarks?


To permanently destroy from database you can use really_destroy! method. Try using @article.really_destroy!