#accepts_nested_attributes_for
does not raise an error when redeclaring for an association
#49055
Labels
#accepts_nested_attributes_for
does not raise an error when redeclaring for an association
#49055
Steps to reproduce
I had to hunt down a weird bug in our Rails app and it turned out that
accepts_nested_attributes_for
had been redeclared for an association with different options (exactly like in the script below). This resulted in the association writer method defined during the second declaration to get utilised instead of the first (I'm unsure yet if it's duplicated or overridden), which is not surprising considering the ordering, but unexpected if you're unaware that the declaration was duplicated.Expected behavior
I think this should raise an error on load. I can't think of a reason not to?
Hoping to address in #49056.
Actual behavior
No error is raised. Autosave validation callbacks and association writers seem to be overridden?
System configuration
Rails version: 7.0.6
Ruby version: 2.7.3
The text was updated successfully, but these errors were encountered: