Active Record 销毁关联异步作业
在后台销毁与已销毁记录关联的记录的作业。
方法
- P
实例公共方法
perform( owner_model_name: nil, owner_id: nil, association_class: nil, association_ids: nil, association_primary_key_column: nil, ensuring_owner_was_method: nil ) 链接
源代码: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/destroy_association_async_job.rb, line 15 def perform( owner_model_name: nil, owner_id: nil, association_class: nil, association_ids: nil, association_primary_key_column: nil, ensuring_owner_was_method: nil ) association_model = association_class.constantize owner_class = owner_model_name.constantize owner = owner_class.find_by(owner_class.primary_key => [owner_id]) if !owner_destroyed?(owner, ensuring_owner_was_method) raise DestroyAssociationAsyncError, "owner record not destroyed" end association_model.where(association_primary_key_column => association_ids).find_each do |r| r.destroy end end