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
ActiveStorage changes in nested model not detected during update #37701
Comments
@camiloforero can you try with
|
@pixeltrix I just tried and it didn't work either. Also, keep in mind that Rails will still detect the changes in the nested model when I update a regular database field, without needing to set the |
Hi @camiloforero - thanks for trying that. The |
I wanted to chime in and say I'm hitting this same issue. I'm the same setup as @camiloforero: A Parent record which I was able to trace it back to where the autosave association checks all the collection records to see if they need to be saved and the Child record returns false even though the ActiveStorage attachment has changed (checked with It seems as though the record is not properly checking ActiveStorage attachments for their changes. My temporary workaround has been to override the
@pixeltrix I created a repository to reproduce the issue here. Let me know if you need any other help in reproducing this issue! |
@willtcarey thanks for the repo - helped track it down. First thing I thought was the associations that Active Storage creates aren't defined with
Anyone want to have a go a fixing it? |
@pixeltrix I created a pull request for a fix. This is my first pull request on rails so I hope I got everything right. I wrote a test to go along with the fix but let me know if I need anything else! |
@pixeltrix Sorry to bother, but I'm checking to see if you need anything else from me to push this through? |
Thank you very much. Your workaround works perfectly. I was having the same issue. |
This did the trick for me as well. Anyone knows what version for Rails will have a fix ? And when will it be released ? |
I'm running into a similar problem on any field in the nested attributes, not just an attached file. I can saved_changes on create, but nothing on the update. I upgraded to 6.0.3.1 and still have the issue. I'm assuming this fix is only for attached files. Should I submit a separate issue? |
Steps to reproduce
Having two models:
and
And updating the Child model through a very vanilla Parent's controller:
example_file
and thename
of aChild
, save, check the resultsexample_file
of aChild
, save, check the resultsExpected behavior
example_file
should be updated. (in the first one thename
is updated as well)Actual behavior
The first case will work as expected. But in the second case, the
Child
with the newexample_file
will not be detected as changed, and the uploaded file will not be savedSystem configuration
Rails version: 6.0.0
Ruby version: 2.6.2
The text was updated successfully, but these errors were encountered: