Skip to content

Issue with destroying collection #13

@bengolden

Description

@bengolden

From the readme, this is a valid use case:

instances = [instance1, instance2]
MyModel.with_explicit_persistence_for(instances) do
  instances.destroy_all
end

However, instances is an array, whereas destroy_all is a method on ActiveRecord_Relation, and passing in a relation causes a Sorbet error. I could make this work as follows:

instances = MyModel.where(some_criteria)
MyModel.with_explicit_persistence_for(instances.to_a) do
  instances.destroy_all
end

but I would think with_explicit_persistence_for should allow an ActiveRecord_Relation to be passed in.

I can draft a PR when I have some free time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions