ruby on rails - Active Record - Delete all dependent values only if its present in child table -
I am working in a rail app, about me : dependent => delete_all
The information is a model
Consider the example below
class TableA & lt; ActiveRecord :: Base has_many: tablebs ,: dependent = & gt; : Delete_all final category TableB & lt; ActiveRecord :: Base is_to: tablea end
If there is a similar foreign key reference in the tablebay that represents the table, using the active record, delete all the related rows from the table by removing the record in the table. Will be removed. / P>
But when there is no consistency in the tablebase, it shows that
unspecified continuous TableA :: TableB
what I try To receive, the active record should be removed from the existing values if there is currently no more dependent value, then ignore the step.
Is this possible?
Thank you, Balan
I think the problem is that Belongs_to should be related to a table in equality. Therefore, change the
tableas
to tablea
as the bottom:
I will give you the link to see the difference between : delete_all < I also suggest looking at
and : deleted
.
Classes TableA & lt; ActiveRecord :: Base has_many: tablebs ,: dependent = & gt; : Delete_all final category TableB & lt; ActiveRecord :: Base is_to: tablea end
Comments
Post a Comment