-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SystemStackError during destroy with ActiveStorage 5.2 #103
Comments
What's the status of this issue? Is there any temporary fix? I'm having issues with it and unable to use acts_as_paranoid with active storage |
For anyone else dealing with this, I'm currently referencing @aymeric-ledorze fork which has a PR up. This is not ideal as I can't move this forked gem to production, but it's the best solution I have at the moment. |
I am facing the same issue. How to deal with it? |
Quick fix. Replace I still have to figure out how to deal with |
Any resolution on how to soft delete without performing the purge callback until it is fully destroyed? |
Any updates on this? |
Yeah, would love to use this gem, but don't want to purge the documents |
Any updates on this? |
So I've got a possible solution that seems to work. I would appreciate any feedback as it doesn't feel particularly solid. In my app #/models/employee.rb
class Employee < ApplicationRecord
acts_as_paranoid
def destroy
@employee = Employee.find(params[:id])
#create a temporary employee object to attach all files to.
@temp_employee = Employee.new(name:"temp", position: "temp")
#attach each of the original employee's files to the temp employee
@employee.files.each do |f|
@temp_employee.files.attach(f.blob)
end
#soft delete the employee
@employee.destroy
#re-attach all the files back
@temp_employee.files.each do |n|
@employee.files.attach(n.blob)
end
@employee.save!
#employee is soft deleted, and the files are attached to the record
end
end UPDATE: as I extended this it got increasingly complicated and I ended up switching to discard instead as it seems more suited to this use case. |
Hello folks, is this issue got resolved or not yet ? |
@navidemad as far as I know this is still a problem. |
I have a test with ActiveStorage in my PR #108 and it seems that the crash is not there anymore. It looks like it got solved by itself with Rails 6.0. Maybe there is another way to trigger this problem but my test does not cover it. |
@jonsinclair1 How did you manage to save |
It's a workaround, but you could consider moving the file upload to a separate model that is not soft-deleted. I haven't tested this, though. class Employee
has_one :file_upload # don't use a `dependent` option
has_many :tasks, dependent: :destroy
end
class FileUpload
has_one_attached :file
belongs_to :employee
end
employee.destroy #=> soft-deletes tasks, keeps file_upload around |
When using both acts_as_paranoid and ActiveStorage on the same model, destroying the model causes a SystemStackError as the stack overflows with lots of nested callbacks around ActiveStorage::Attachment purging.
As a minimum this error shouldn't occur, but some fuller support for soft deletion with ActiveStorage would be great, allowing for the attachment+blob to remain until really deleted.
Here's a simple test application showing the error: https://github.com/domcleal/acts_as_paranoid_with_activestorage
With this model:
Example stack trace:
The text was updated successfully, but these errors were encountered: