سؤال

Usually, if we specify :dependent => :destroy or :dependent => :delete AR call DELETE query for each row of association. If we use ModelName.delete(batch_of_ids) AR call single resuest like DELETE ... FROM ... WHERE ... IN (batch_of_ids). Is any possibility to destroy association by single query without definitions own methods? For example something like activerecord-import gem, but for delete.

هل كانت مفيدة؟

المحلول

You can use dependent: :delete_all to delete all of the records in a single query.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top