Should #save also save nested/associated model objects? #73
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://github.com/apotonick/reform/blob/master/lib/reform/form/active_record.rb#L39
When I tried out https://github.com/gogogarrett/reform_example, I noticed this bug there: when you edit an album and change one of the song titles, those changes are lost — they are not saved!
Since it is so easy to assume that associated model objects are going to be saved, perhaps this method should automatically save them... That would be my vote anyway.
I don't know how hard that would be though. I started adding a test for this in
test/active_record_test.rb
but then discovered that the test setup only has one ActiveRecord model available —Artist
, which doesn't have any has_many association yet...