Open BrandonKlotz opened 10 months ago
Hello @BrandonKlotz, sorry for the delay here.
Here is an example for an ActionModel that TargetsMany to delete Contact records. I'd expect my callback to ensure the object fails processing and is added to failed_ids
I see that the screenshot you posted after that has the callback in it. Are you putting the callback directly into the TargetsMany model? I was able to persist failed_ids
with a setup like this:
> rails generate super_scaffold Project Team name:text_field
> rails generate super_scaffold:action_models:targets_many Archive Project Team
In app/models/project.rb
:
before_destroy :raise_invalid_destroy, if: -> { true }
# 🚅 add callbacks above.
# 🚅 add delegations above.
def raise_invalid_destroy
raise "Error"
end
# 🚅 add methods above.
In app/models/projects/archive_action.rb
:
def perform_on_target(project)
project.destroy!
end
This should be enough since we're raising an error specifically on perform_on_target
.
Right now if I force an object to raise being evaluated in
perform_on_target
thefailed_ids
attribute will not be updated with the record id. I believefailed_ids
is not working at all for ActionModels right now.Here is an example for an ActionModel that TargetsMany to delete Contact records. I'd expect my callback to ensure the object fails processing and is added to
failed_ids
For some reason it seems like
failed_ids
isnil
when trying to<<
failed object ids into the attribute.I tried to pull the gem locally and ensure
failed_ids
is an Array but this resulted in the ActionModel retrying to perform on the record over and over.Ideally, in the DeleteAction, I'd be able to shovel and persist
ids
that didn't meet the requirement to be deleted, but this does not seem to be persisting on the ActionModel'sfailed_ids
attribute.