-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Active Storage Issue #448
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This happened to me today with Rails 7.1.3 and ANS 3.6.0. I have worked around the issue by switching the order in the model: class Record < ActiveRecord::Base
# broken
acts_as_nested_set
has_one_attached :attachment
# works
has_one_attached :attachment
acts_as_nested_set
end |
Digging deeper, it appears that the various calls to |
Turns out this is expected behavior?? # lib/active_storage/attached/model.rb
module ActiveStorage::Attached::Model
def reload(*) # :nodoc:
super.tap { @attachment_changes = nil }
end
end Also perhaps related: rails/rails#40630 Do we try to campaign to get this fixed in future Rails releases? Or work around it in ANS? Both? At the very least, a note in the README. |
I have successfully worked around this issue by undoing the attachment reset behavior in ActiveStorage: class Record < ActiveRecord::Base
has_one_attached :attachment # must come before acts_as_nested_set
acts_as_nested_set
# undo ActiveStorage's reset behavior
def reload(*)
before = @attachment_changes
super.tap { @attachment_changes = before }
end
end So the question is, where do we go with this to resolve the apparent incompatibility between AS and ANS? Should we incorporate these workarounds into ANS? |
@parndt Would you mind reopening this issue? I plan to figure this out next. |
I found a strange behaviour when using
acts_as_nested_set
andhas_one_attached
on the same model.If
acts_as_nested_set
is placed abovehas_one_attached
acts as the object is a newly created item, the active storage attachment is lost when saved.But if you create your item and the go to attach the image using active storage it works fine.
If you place
has_one_attached
aboveacts_as_nested_set
then the behaviour changes slightly, it stall fails.The text was updated successfully, but these errors were encountered: