Gusto / Gusto/explicit_activerecord
Issue with destroying collection
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 7
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the README example and trace the implementation of with_explicit_persistence_for, especially how it handles an ActiveRecord_Relation versus an array. Check the existing behavior around destroy_all and Sorbet errors. Done means the documented relation use case works without requiring to_a and is covered by the project's relevant checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rails, ruby
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100