Comments (4)
This is an interesting one! It looks like because updater_id
on the nested record is changing, an autosave is triggered (this is always enabled for nested attributes), causing the foreign key on the nested record to be set here despite it not changing:
Interestingly, this isn't an issue on belongs_to
which already only sets the nested record's foreign key if it's changing:
I've got a fix passing against your script, just adding some coverage before I get a PR up.
from rails.
Got this up: #50901
from rails.
Thank you, that looks good and gets all my actual tests passing. This seems to be mirroring what #46759 did for belongs_to
, I found #46758 while searching for similar issues but didn't connect the dots.
from rails.
Thank you, that looks good and gets all my actual tests passing. This seems to be mirroring what #46759 did for
belongs_to
, I found #46758 while searching for similar issues but didn't connect the dots.
Ah nice find, I'll reference it in my PR, thanks!
from rails.
Related Issues (20)
- accepts_nested_attributes_for doesn't validate unchanged objects HOT 2
- Rails server --pid option does not seem to work as expected. Also no documentation found. HOT 2
- `ActiveRecord::NotNullViolation` for Missing Enum Default in Rails 7 HOT 7
- No connection pool for 'ActiveRecord::Base' found for the 'reading' role. #275 HOT 4
- trix with rails 7.0 giving TypeError HOT 2
- in guides.rubyonrails documentation of threads: missing info about db access HOT 1
- HasMany/HasOne associations: combining `:through` and a scope including a `.merge` leads to missing table HOT 1
- [Question] Why doesn't set_pk_sequence! support the parameter for is_called? HOT 5
- Rails 6.0.6.1 transaction rollback doesn't reload object HOT 1
- Error `undefined method `start_with?' for nil` when logging
- new_framework_defaults initializer for Rails 7.1 not setting ActiveRecord.run_after_transaction_callbacks_in_order_defined
- [Feature Request][CSP] Support for multiple Content Security Policies HOT 2
- ActionCable: Invalid channel causes repeated subscription attempts
- Code generation memory bloat post alias fix HOT 8
- Rails throws an error when sending invalid UTF-8 query param HOT 1
- Lazy default_scope evaluation in joined models loses original context
- Some Rails integration tests break with rack 3.1 HOT 4
- ActionText Editor Previews uploaded pre 7.1.3.4 are broken in 7.1.3.4 after a resave HOT 13
- Inversion of associations with :through don't work until it's saved
- Incorrect `has_many through` load with custom association name and custom keys type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rails.